Results 1 to 3 of 3

Need help in login vba code to unhide specific sheets depends on login info

Threaded View

  1. #1
    Registered User
    Join Date
    10-26-2018
    Location
    Turkey
    MS-Off Ver
    2013
    Posts
    3

    Question Need help in login vba code to unhide specific sheets depends on login info

    Hello there,

    Actually I have found this code and it does what I need but there's 1 problem that if you use a tool like kutools and click the option of unhide all sheets then all sheets will be hidden so what I need to add to the following code is when the username and password are correct in addition of visible the sheet which required the sheet to be unprotected so after visible the sheet I need to protect workbook structure again... so how I can perform that in the following code:
    Private Sub Workbook_Open()
    Dim Sh As Worksheet
    Dim UserName As String
    Dim Password As String
    Dim ThisCell As Range
    Dim c As Long
    For Each Sh In ThisWorkbook.Worksheets
    If ThisWorkbook.ProtectStructure = True Or ThisWorkbook.ProtectWindows = True Then ThisWorkbook.Unprotect WPwd
    Sh.Activate
    If Sh.Name <> "WELCOME SCREEN" Then
    Sh.Visible = xlSheetVeryHidden
    End If
    Next Sh
    UserName = InputBox("Please enter your user name.")
    Password = InputBox("Please enter password.")
    For Each ThisCell In Sheets("User List").Range("A2:A" & Sheets("User List").Range("A65536").End(xlUp).Row)
    If UCase(ThisCell.Value) = UCase(UserName) And UCase(ThisCell.Offset(, 1).Value) = UCase(Password) Then
    MsgBox "Access Granted"
    For c = 2 To 4
    'This is the number of sheets from C1 to E1
    If ThisCell.Offset(, c).Value <> "" Then
    Sheets(Sheets("User List").Cells(1, c + 1).Value).Visible = xlSheetVisible
    End If
    Next c
    Exit Sub
    End If
    Next ThisCell
    MsgBox "Access Denied"
    ThisWorkbook.Close
    End Sub
    this code placed in THISWORKBOOK

    the idea of the code is to create WELCOME SCREEN sheet and User List sheet which contain a table with username + password + sheet1 + sheet2 + .... as columns
    under the sheet1, sheet2 I just insert "x" to let the sheet visible for the user or "" empty if I want the sheet to not be visible for the user, the only problem that the hidden sheet can be visible by kutools or maybe another tools when you click hide/unhide all sheets which make everything useless and weak.

    Thanks in Advanced
    Last edited by alansidman; 05-12-2019 at 08:07 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Create login screen with multiple login id and password
    By anilpatni1234 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-01-2018, 10:14 AM
  2. Replies: 2
    Last Post: 09-28-2017, 03:49 PM
  3. Replies: 1
    Last Post: 04-30-2017, 08:26 PM
  4. Any excel formula to get first login and last login data
    By sandesh joshi in forum Excel General
    Replies: 5
    Last Post: 07-11-2014, 11:18 AM
  5. find the login user and saving /login the name
    By belkin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-03-2008, 08:24 AM
  6. Login ID Unhides specific sheets!!
    By Macdave_19 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-17-2007, 06:54 AM
  7. Hide/Unhide worksheets based on login?
    By jej1216 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-27-2006, 11:20 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1