Error in VBA coding excel, login and security check
Hi everyone. Please help me to debug errors in Login and Security code of VBA in excel.
Code is below. I have tried to highlight code error in closed stars which were shown after debug.
Option Explicit
Sub CheckUser()
Dim UserRow, SheetCol As Long
Dim SheetNm As String
With Sheet1
.Calculate
If .Range("B8").Value = Empty Then 'Incorrect Username
MsgBox "Please enter a correct User name"
Exit Sub
End If
If .Range("B7").Value <> True Then 'Incorrect password
MsgBox "Please enter a correct password"
Exit Sub
End If
LoginForm.Hide
.Range("B5,B6").ClearContents
UserRow = .Range("B8").Value 'User Row
For SheetCol = 8 To 13
SheetNm = .Cells(4, SheetCol).Value 'Sheet Name
If .Cells(UserRow, SheetCol).Value = "Ð" Then
Sheets(SheetNm).Unprotect "123"
Sheets(SheetNm).Visible = xlSheetVisible
End If
If .Cells(UserRow, SheetCol).Value = "Ï" Then
Sheets(SheetNm).Protect "123"
Sheets(SheetNm).Visible = xlSheetVisible
End If
If .Cells(UserRow, SheetCol).Value = "x" Then Sheets(SheetNm).Visible = xlVeryHidden
Next SheetCol
End With
End Sub
Sub CloseWorkbook()
Sheet6.Activate
Dim WkSht As Worksheet
For Each WkSht In ThisWorkbook.Worksheets
If WkSht.Name <> "Start" Then WkSht.Visible = xlSheetVeryHidden
Next WkSht
ThisWorkbook.Save
End Sub