View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
aca[_2_] aca[_2_] is offline
external usenet poster
 
Posts: 1
Default Launching a macro by double-clicking on active cell


Thank you for your quick response.
I'm going to try it, though I'am a very, very beginner and I may not be
able to do steps that are obvious for you, programmers.
But that is no less merit on your part.
God bless you.
aca

Patrick Molloy Wrote:
use the sheet's 'before doubleclick event'
to get to the sheet's code page, right click while pointing at the
sheet's
tab, then select 'View Code'

add this:

Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As
Boolean)
If Target.Value = "GO" Then
Cancel = True
Call MyProcedure
End If
End Sub
Sub MyProcedure()
MsgBox "done"
End Sub

If the cell contains the word GO then the procedure is called.

This alternative runs a procedure whose name is in the cell that is
double-clicked.
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As
Boolean)
If Target.Value < "" Then
On Error Resume Next
Run Target.Value
Cancel = Err.Number = 0
End If
End Sub

In this case the procedure must be public and in a standard module.
There's
an error trap, so if a sub exists it runs, if not, the double click
event
continues.

HTH



"aca" wrote in
message
...

How can I make my macro to be executed when the user double-clicks

on
the active cell of Excel?
Thanks for any help.
aca


--
aca

------------------------------------------------------------------------
aca's Profile:
http://www.excelforum.com/member.php...o&userid=25933
View this thread:

http://www.excelforum.com/showthread...hreadid=393051



--
aca
------------------------------------------------------------------------
aca's Profile: http://www.excelforum.com/member.php...o&userid=25933
View this thread: http://www.excelforum.com/showthread...hreadid=393051