Overriding events of excel sheet using VBA
Posted
by Rashmi Pandit
on Stack Overflow
See other posts from Stack Overflow
or by Rashmi Pandit
Published on 2010-03-29T10:33:54Z
Indexed on
2010/03/29
11:03 UTC
Read the original article
Hit count: 332
excel-vba
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 :)
© Stack Overflow or respective owner