Hi Marcel.
Paste the code below to the sheets code module - right click
sheet tab > view code.
Private Sub Worksheet_BeforeRightClick(ByVal Target As
Range, Cancel As Boolean)
Cancel = False 'to turn on right click menu
If Not Intersect(Target, [B2]) Is Nothing Then
Cancel = True 'to turn off right click menu
Application.Run "TestM"
End If
End Sub
To run this, first make sure you have the procedure named
where 'TestM' is in an ordinary code module.
I used the cell B2, so change this to the one you wish to
have and right click this cell to run the called procedure.
Right click any other cell won't fire the event, and you
get to see the right click menu again.
Regards
Robert McCurdy
----- Original Message -----
From: "Marcel Zentveld" <marcelzentveld YAHOO.COM>
To: <EXCEL-G PEACH.EASE.LSOFT.COM>
Sent: Monday, February 13, 2006 7:48 PM
Subject: Assigning a macro to a cell, not to a button or
image
> Hi there,
>
> Is it possible to assign a macro to a cell or the
content of a cell, and not to a button or image?
>
> Regards,
>
> Marcel.
------------------------------------------------------------
--------------
The EXCEL-G list is hosted on a Windows NT(TM) machine
running L-Soft
international's LISTSERV(R) software. For
subscription/signoff info
and archives, see htt
p://peach.ease.lsoft.com/archives/excel-g.html .
COPYRIGHT INFO:
http://peach.ease.lsoft.com/scripts/wa
.exe?SHOWTPL=COPYRIGHT&L=EXCEL-G
|