capture right mouse button click event on cell

R

Reinhard Thomann

Hi,
how can i capture the right mouse button click event on a cell. I'd like to
enable/disable commands of the context menu in dependence to the selected
column.

TIA
Reinhard
 
B

Bob Phillips

Hi Reinhard,

Here is some event code to do it. Change th 9 to your column number.

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)
If Target.Column = 9 Then
Cancel = True
End If
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top