Thanks Tom,
I did not know you could also break running code using other key combinations besides "Ctrl-Break" like: "To exit the procedure, double click any cell and then either hit Esc, Enter, or select any cell."
I always used Ctrl-Break [Mainframe days] and never thought to explore other combinations. Should have know, there is always more than one way to do something!
Darril,
You have two Events within the Sheet Module that you can capture Mouse Clicks with:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
End Sub
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
End Sub
Note: You do not have a Left Click Button Event, to get that functionallity you use:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
Which works for all physical selection methods [depending on the code used a selection made by other code may not trigger this event, hence the "physical." More often than not though the problem is more "code re-triggering the selection Event, throwing it into a loop!], not just the mouse selection [key board and cursor].
You can also trap on a UserForm [Using an API that Ivan mentioned]:
'Standard Module declarations, like: Module1.
Public Const WM_MOUSEMOVE = &H200
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const WM_LBUTTONDBLCLK = &H203
Public Const WM_RBUTTONDOWN = &H204
Public Const WM_RBUTTONUP = &H205
Public Const WM_RBUTTONDBLCLK = &H206
Public Const WM_MBUTTONDOWN = &H207
Public Const WM_MBUTTONUP = &H208
Public Const WM_MBUTTONDBLCLK = &H209
Private Sub UserForm_MouseMove(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'UserForm module code!
Dim MyX As Long
[B1] = ActiveWindow.PointsToScreenPixelsX(X)
MyX = [B1]
[B1] = ActiveWindow.PointsToScreenPixelsX(X)
MyX = [B1]
Select Case MyX
Case WM_MOUSEMOVE
UserForm1.Caption = "MouseMove!"
Case WM_LBUTTONDOWN
UserForm1.Caption = "Left MouseDown"
Case WM_LBUTTONUP
UserForm1.Caption = "Left MouseUp"
Case WM_LBUTTONDBLCLK
UserForm1.Caption = "Left DoubleClick"
Case WM_RBUTTONDOWN
UserForm1.Caption = "Right MouseDown"
Case WM_RBUTTONUP
UserForm1.Caption = "Right MouseUp"
Case WM_RBUTTONDBLCLK
UserForm1.Caption = "Right DoubleClick"
End Select
End Sub