(Solved) – Unable to make sheet visible when value is true

  • by

I am trying to make the admin sheet (Sheet2) visible when the cell value is “Yes”. This is the code:

Dim WkSht As Worksheet
If Sheet2.Range("B6").Value = True Then
    For Each WkSht In ThisWorkbook.Worksheets
        If WkSht.Name = "Admin" Then
            If Sheet2.Range("B8").Value = "Yes" Then 'Admin
                WkSht.Visible = xlSheetVisible
                WkSht.Visible = xlSheetVeryHidden
            End If
        Else: 'Not Admin
            WkSht.Visible = xlSheetVisible
        End If
    Next WkSht
    Sheet2.Range("B7").Value = Sheet2.Range("B4").Value 'Set Current User
MsgBox "Please enter a correct Username and Password"
End If
End Sub

Picture of my Sheet2
There’s a simple Yes,No data validation list in my Admin column. I have checked for hidden spaces or characters. I do not know what I am doing wrong. I assigned the macro to a login button on Sheet3.

Leave a Reply

Your email address will not be published. Required fields are marked *