Below is my Worksheet_BeforeRightClick() sub routine. It checks for the status of my ToggleButton, Edit, and if it is True, Right-Click runs sub Change_Shape. If it is False, Right-Clicking runs sub WorksheetDetail.
The problem is, Change_Shape is located in a module that is imported in when Edit.Value = True and exported out when Edit.Value = False. When I right-click with Edit.Value = True, it works fine. However, if I try to right-click with Edit.Value = False, I get a compile error, saying that Change_Shape is not defined. What I don't understand is, why is it even going into the Edit.Value = True portion of the If statement if Edit.Value = False? If I'm not calling that sub, why does it need to be defined?
Can anyone please assist me in modifying the code so that it will work properly? It would be greatly appreciated. Thanks!
The problem is, Change_Shape is located in a module that is imported in when Edit.Value = True and exported out when Edit.Value = False. When I right-click with Edit.Value = True, it works fine. However, if I try to right-click with Edit.Value = False, I get a compile error, saying that Change_Shape is not defined. What I don't understand is, why is it even going into the Edit.Value = True portion of the If statement if Edit.Value = False? If I'm not calling that sub, why does it need to be defined?
Can anyone please assist me in modifying the code so that it will work properly? It would be greatly appreciated. Thanks!
Code:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
If Edit.Value = True Then
Change_Shape
Cancel = True
ElseIf Edit.Value = False Then
WorksheetDetail
Cancel = True
End If
End Sub