Overriding events of excel sheet using VBA
- by Rashmi Pandit
Hi,
I need to programmatically override the following events of a worksheet:
BeforeDoubleClick
SelectionChange
BeforeRightClick
I have been able to override the OnActivate event using the following code:
sheet.OnSheetActivate = "MyOwn_Activate"
Private Sub MyOwn_Activate()
myForm.Show
End Sub
I have implemented BeforeDoubleClick on similar lines:
sheet.OnDoubleClick = "My_BeforeDoubleClick"
Private Sub My_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
...
End Sub
However, an 'argument not optional' error is thrown at run-time when user double clicks a cell on the sheet. Can someone please suggest how should I pass the paramters?
In addition, I am not able to find event names for SelectionChange & BeforeRightClick. I tried:
sheet.BeforeRightClick = "My_BeforeRightClick"
sheet.SelectionChange = "My_SelectionChange"
But, both the above lines do not work.
Any help/ suggestion is greatly appreciated.
Thanks :)