How to create user-form login with User id & Password in excel with vba | Only User form will open

Опубликовано: 23 Октябрь 2024
на канале: HASAN ACADEMY
2,264
38

To create a user-form login with a User ID and Password in Excel with VBA that only opens the user form, you can follow these steps:

Open Excel and press "Alt + F11" to open the VBA editor.

In the editor, select "Insert" from the top menu and choose "UserForm" to create a new user form.

Add two text boxes to the user form, one for the User ID and one for the Password.

Add a command button to the user form and name it "OK."

Double-click the "OK" button to open the code editor and enter the following code:

vbnet
Copy code
Private Sub OK_Click()
If TextBox1.Value = "Your User ID" And TextBox2.Value = "Your Password" Then
UserForm1.Hide
'Here you can write the code for opening the main excel file
Else
MsgBox "Incorrect User ID or Password. Please try again."
End If
End Sub
Replace "Your User ID" and "Your Password" with your desired user ID and password.

Save the user form and close the VBA editor.

Press "Alt + F8" to open the Macros window.

Click "Options" and assign a shortcut key to the user form macro.

Close Excel and reopen it.

Press the shortcut key to open the user form.

Enter the correct User ID and Password to open the main Excel file.

By following these steps, you can create a user-form login with a User ID and Password in Excel with VBA that only opens the user form.





Login and password previous Lecture link :
1.    • Excel VBA Bangla Tutorial 47  : How t...  
2.    • Excel VBA Bangla 63: How to create pa...  



#Hasan_Academy #Macro_Bangla_Tutorial #VBA_Bangla_Tutorial

COMMUNICATE WITH HASAN ACADEMY
[email protected]

Facebook page
  / hasanacademybanglatutorial  



Code for this Lecture :

Private Sub CommandButton1_Click()

If TextBox1.Value = "" Then
If TextBox2.Value = "" Then
MsgBox "Please Input the User Name and the Password"
Else
MsgBox "Please Input the User Name"
End If

Else
If TextBox1.Text = Sheets("Admin").Range("B2") Then
If TextBox2.Value = "" Then
MsgBox "Please Input the Password"
ElseIf TextBox2.Text = Sheets("Admin").Range("C2") Then
MsgBox "Welcome Mr Hasan"
Me.Hide: Application.Visible = True

Sheets("Admin").Visible = True
Sheets("Inventory").Visible = True
Sheets("Primary").Visible = True
Sheets("Secondary").Visible = True

Else
MsgBox "Please Input the right User Name and the right Password"
End If
Else
If TextBox2.Value = "" Then
MsgBox "Please Input the Password"

End If
End If

If TextBox1.Text = Sheets("Admin").Range("B3") Then
If TextBox2.Value = "" Then
MsgBox "Please Input the Password"
ElseIf TextBox2.Text = Sheets("Admin").Range("C3") Then

MsgBox "Welcome Mr Shams"
Me.Hide: Application.Visible = True

Sheets("Admin").Visible = False
Sheets("Inventory").Visible = True
Sheets("Primary").Visible = True
Sheets("Secondary").Visible = True

Else
MsgBox "Please Input the right User Name and the right Password"
End If
Else
If TextBox2.Value = "" Then
MsgBox "Please Input the Password"


End If
End If

If TextBox1.Text = Sheets("Admin").Range("B4") Then
If TextBox2.Value = "" Then
MsgBox "Please Input the Password"
ElseIf TextBox2.Text = Sheets("Admin").Range("C4") Then
MsgBox "Welcome Mr Moni"
Me.Hide: Application.Visible = True

Sheets("Admin").Visible = False
Sheets("Inventory").Visible = True
Sheets("Primary").Visible = True
Sheets("Secondary").Visible = True

Else
If TextBox2.Value = "" Then
MsgBox "Please Input the Password"

End If
End If
End If
End If

End Sub


Private Sub CommandButton2_Click()
Unload UserForm1
UserForm1.Show

End Sub



Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
ThisWorkbook.Application.Quit
End Sub

Most popular video Link :
   • Excel VBA Bangla Tutorial 48 : Data E...      • Excel VBA Bangla Tutorial 50 : Create...      • Excel tutorial Bangla 24 : Top 10 Use...      • Excel VBA Bangla Tutorial 54: Add- Em...      • Introduction to Pivot Tables-Charts-a...      • Excel VBA Bangla Tutorial 49 : Invoic...  



How to create user-form login with User id & Password by VBA in Bangla
hasan academy,advance userform in excel,userform in bangla,user id,password,how to create login id,how to create userform,how to create user-form login with user id & password by vba in bangla,how to create userform in bangla,vba bangla tutorial,excel vba bangla tutorial,how to create user-form,login with user id,user id & password by vba,create user-form,user-form login with user id & password,login with user id & password,excel vba bangla tutorial
Most of the people is think about that how I will learn .But they didn't get any idea & trustworthy source. Don't hesitated Hasan Academy with you. You will learn from here, Excel, Excel Chart, Pivot Table, Vlookup, Formula function