View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Brotha Lee Brotha Lee is offline
external usenet poster
 
Posts: 43
Default Right Click auto run macro

Hi Steven,

Yes this can be done. In the VBA editor click on ThisWorkbook and add the
following code there. This will cause a macro to run whenever you right click
on any sheet in your workbook.
The code should be something like this:

Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target
As Range, Cancel As Boolean)
application.run "YourMacroName"
cancel = true
End Sub

If you want to attach to a specific sheet use the respective worksheet event.

"Steven" wrote:

I would like to change the Right Mouse click on a basic excel worksheet so it
does not work as the conventional method of showing a list of available
processes, like copy, paste etc.... What I would like for it to do is to run
a specific macro automatically right off the Right Click. Basically then the
Right Click would have only one function which is to run that macro. Can
this be done.

Thank you,

Steven