Skip to content

Free Excel Training 2022

Excel Training Tutorials 2022

  • Home
    • About
    • Contact
    • Privacy Policy
  • Excel Essentials
  • Excel Functions
    • Excel 2003
    • Excel 2007
    • Excel 2010
  • Excel in Hindi
  • Excel VBA
    • Excel 2003 VBA
    • Excel 2007 2010 2013 VBA
  • YouTube
    • YouTube Advanced VBA
    • YouTube Hindi
  • Books
  • What’s New

Month: May 2016

How to check login password open specific worksheet

Posted on May 17, 2016May 17, 2016 by Dinesh Kumar Takyar

How to check login, password and open specific worksheet with VBA. A user wants to be able to login with his user name and password. Another worksheet contains a list of user names and passwords. As soon as he inputs his user name and password, these credentials are checked against the already existing data. If the user name (login) and password match then he can view a worksheet with his user name. Watch the training video.

https://www.exceltrainingvideos.com/wp-content/uploads/2016/05/how-to-lookup-login-password-open-specific-worksheet.mp4

Watch this video on YouTube.

Here’s the complete VBA code:

Private Sub Workbook_Open()
Dim i, LastRow
LastRow = Sheets(“UserData”).Range(“A” & Rows.Count).End(xlUp).Row
Sheets(“Login”).Visible = xlSheetVisible
For Each ws In Sheets
If UCase(ws.Name) <> “LOGIN” Then
ws.Visible = xlSheetVeryHidden
End If
Next
retry:
ulogin = UCase(InputBox(“Please enter your username.”, “Username”))
If ulogin = “” Then
MsgBox “No username entered. Closing application.”, vbCritical, “Close”
Application.DisplayAlerts = False
Application.Quit
Exit Sub
End If
uPasswd = InputBox(“Please enter your case sensitive password.”, “Password”)
If uPasswd = “” Then
MsgBox “No password entered. Closing application.”, vbCritical, “Close”
Application.DisplayAlerts = False
Application.Quit
Exit Sub
End If
For i = 2 To LastRow
chkCred = UCase(Sheets(“UserData”).Cells(i, “A”).Value) & _
Sheets(“UserData”).Cells(i, “B”).Value
If chkCred = ulogin & uPasswd Then
For Each ws In Sheets
‘ws.Visible = xlSheetVisible
If UCase(ws.Name) = ulogin Then
ws.Visible = xlSheetVisible
End If
Next ws
Sheets(“Login”).Visible = xlSheetVeryHidden
Sheets(“UserData”).Visible = xlSheetVeryHidden
recFound = “Yes”
Else
End If
Next i
If recFound <> “Yes” Then
tryAgain = MsgBox(“Username and Password not found. Try again?”, _
vbCritical + vbYesNo, “No Record”)
Select Case tryAgain
Case Is = vbYes
GoTo retry
Case Is = vbNo
Application.DisplayAlerts = False
Application.Quit
Exit Sub
End Select
End If
End Sub

Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
If Sheets(“UserData”).Visible = xlSheetVisible Then
Sheets(“UserData”).Visible = xlSheetVeryHidden
Target.Offset(1).Select
Exit Sub
End If
Passwd = InputBox(“Enter the access password”, “Password”)
If Passwd = “OpenMeUp” Then
Sheets(“UserData”).Visible = xlSheetVisible
Else
MsgBox “Invalid entry!”, vbCritical, “Close”
End If
Target.Offset(1).Select
End Sub

 

Reference: Excel VBA – Username and Password from Lookup?

Posted in Excel VBA 2013Tagged How to check login password open specific worksheet, how to check login password with vba, open specific worksheet with vba 2 Comments

Posts navigation

Older posts
Newer posts

Change Language

en English
af Afrikaanssq Albanianam Amharicar Arabichy Armenianaz Azerbaijanieu Basquebe Belarusianbn Bengalibs Bosnianbg Bulgarianca Catalanceb Cebuanony Chichewazh-CN Chinese (Simplified)zh-TW Chinese (Traditional)co Corsicanhr Croatiancs Czechda Danishnl Dutchen Englisheo Esperantoet Estoniantl Filipinofi Finnishfr Frenchfy Frisiangl Galicianka Georgiande Germanel Greekgu Gujaratiht Haitian Creoleha Hausahaw Hawaiianiw Hebrewhi Hindihmn Hmonghu Hungarianis Icelandicig Igboid Indonesianga Irishit Italianja Japanesejw Javanesekn Kannadakk Kazakhkm Khmerko Koreanku Kurdish (Kurmanji)ky Kyrgyzlo Laola Latinlv Latvianlt Lithuanianlb Luxembourgishmk Macedonianmg Malagasyms Malayml Malayalammt Maltesemi Maorimr Marathimn Mongolianmy Myanmar (Burmese)ne Nepalino Norwegianps Pashtofa Persianpl Polishpt Portuguesepa Punjabiro Romanianru Russiansm Samoangd Scottish Gaelicsr Serbianst Sesothosn Shonasd Sindhisi Sinhalask Slovaksl Slovenianso Somalies Spanishsu Sudanesesw Swahilisv Swedishtg Tajikta Tamilte Teluguth Thaitr Turkishuk Ukrainianur Urduuz Uzbekvi Vietnamesecy Welshxh Xhosayi Yiddishyo Yorubazu Zulu

Please click the icon to access all YouTube videos, if you can't see the video on the main page:

View All Posts

View All Pages

Share with Friends:
              

Create a website that's free with GoDaddy!
Proudly powered by WordPress | Theme: sosimple by Fernando Villamor Jr..

Copyright ©2023 exceltrainingvideos.com