Abdulkhadar
Board Regular
- Joined
- Nov 10, 2013
- Messages
- 165
- Office Version
- 2019
- 2010
- Platform
- Windows
Hi Excel Experts,
Below VB shows run time error '13' what's wrong in the vb. please help me to solve the problem.
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
Thanks in advance,
Below VB shows run time error '13' what's wrong in the vb. please help me to solve the problem.
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
Thanks in advance,