Hi guys
I am trying to run the code below but I get a run time error 91 stating: "Object variable or With block variable not set".
When I use the debugger it says that the error lies in the second line of code. I.e.
I hope that someone on this forum can see a way to fix it as it is way beyond my VBA knowledge.
Thank you!
I am trying to run the code below but I get a run time error 91 stating: "Object variable or With block variable not set".
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Intersect(Target, Range("O25:O50")).Value = 2 Then
MsgBox "This is a warning message", vbOKOnly & vbCritical, "Wrong Data Entry"
End If
If Not Intersect(Target, Range("G8")) Is Nothing Then
Q = MsgBox("Do you want end session?", vbQuestion + vbYesNo, "OPTION")
If Q = vbYes Then
Sh.Protect "Carlsberg" 'Substitute actual password here
End If
End If
End Sub
When I use the debugger it says that the error lies in the second line of code. I.e.
Code:
If Intersect(Target, Range("O25:O50")).Value = 2 Then
I hope that someone on this forum can see a way to fix it as it is way beyond my VBA knowledge.
Thank you!