VBA not working show run time error '13'

Abdulkhadar

Board Regular
Joined
Nov 10, 2013
Messages
165
Office Version
  1. 2019
  2. 2010
Platform
  1. 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,
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Check the value of UserRow & SheetCol when the error happens. There is a good chance that the cell shows an error.
 
Last edited:
Upvote 0
Check the value of UserRow & SheetCol when the error happens. There is a good chance that the cell shows an error.

Thanks for quick reply sir,

In Sheet1 i use VB as below it runs perfect but the said VB is not working


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, cancel As Boolean)
If Not Intersect(Target, Range("H5:M24")) Is Nothing Then

If Target.Value = "Ð" Then
Target.Value = "Ï"
Exit Sub
End If
If Target.Value = "x" Then Target.Value = "Ð"
If Target.Value = "Ï" Then Target.Value = "x"
If Target.Value = Empty Then Target.Value = "Ð"
End If

If Not Intersect(Target, Range("G5:G24")) Is Nothing Then
If Target.Value = "Ð" Then
Range("G" & Target.Row & ":M" & Target.Row).Value = "Ï"
Exit Sub
End If
If Target.Value = "x" Then Range("G" & Target.Row & ":M" & Target.Row).Value = "Ð"
If Target.Value = "Ï" Then Range("G" & Target.Row & ":M" & Target.Row).Value = "x"
If Target.Value = Empty Then Range("G" & Target.Row & ":M" & Target.Row).Value = "Ð"
End If
End Sub
 
Upvote 0
Abdulkhadar,
I would use:

.range("B5").value=""
.range("B6").value=""

this will set the values of cells B5 and B6 to nothing

Hope that helps,
Computerman
 
Upvote 0
What is the value in B8 & is it as the result of a formula?
 
Upvote 0
Abdulkhadar,
I would use:

.range("B5").value=""
.range("B6").value=""

this will set the values of cells B5 and B6 to nothing

Hope that helps,
Computerman

when use both range problem as it is, shows run time error, but if use only
.range("B6").value=""
it works :laugh:
 
Upvote 0

Forum statistics

Threads
1,224,830
Messages
6,181,227
Members
453,025
Latest member
Hannah_Pham93

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top