Hello there , I am trying to create an excel app on VBA, it is showing Run-time error 13: Type Mismatch error
If anyone could help me would be very nice of you :)
The code is below:
'work with the lock/unlock button on admin starts
For SheetCol = 5 To 11
SheetNm = .Cells(2, SheetCol).Value 'Sheet Name
If .Cells(UserRow, SheetCol).Value = "Ð" Then
Sheets(SheetNm).Unprotect "5896"
Sheets(SheetNm).Visible = xlSheetVisible
End If
If .Cells(UserRow, SheetCol).Value = "Ï" Then
Sheets(SheetNm).Protect "5896"
Sheets(SheetNm).Visible = xlSheetVisible
End If
If .Cells(UserRow, SheetCol).Value = "x" Then Sheets(SheetNm).Visible = xlVeryHidden
Next SheetCol
End With
'work with the lock/unlock button on admin ends
Hello John,
Thank you so much for your reply, and so sorry, i do not specify the line previously.
the problem is in the line below :
If .Cells(UserRow, SheetCol).Value = "Ð" Then
Your suggestion will be helpful and kind, Thanks !
A type mismatch error always indicates that you are using the wrong kind of variable. Excel is expecting a Variant variable for a cell value, not a string. Using
CVar("Ð")
should fix that.
Type conversion functions
But you haven't included your Dim statement for UserRow, make sure that variable is numeric as well.