ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Launching a macro by double-clicking on active cell (https://www.excelbanter.com/excel-programming/336430-launching-macro-double-clicking-active-cell.html)

aca

Launching a macro by double-clicking on active cell
 

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


Piranha[_28_]

Launching a macro by double-clicking on active cell
 

aca,

When you go into the VBA Edit window for your worksheet module.
Click on the left slot and choose "Worksheet"
Then click on the right slot and you wil have some selections.
Choose this one:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)

This help?
Dave
aca Wrote:
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



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


Jim Thomlinson[_4_]

Launching a macro by double-clicking on active cell
 
On the sheet tab you want to react to the double click, right click the tab
and select veiw code. This will take you to the VBE. Paste this code in and
you are off and running...

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Cancel = True
MsgBox Target.Address
End Sub
--
HTH...

Jim Thomlinson


"aca" wrote:


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



Patrick Molloy

Launching a macro by double-clicking on active cell
 
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[_2_]

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


aca[_3_]

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 b
able to do steps that are obvious for you, programmers.
But that is no less merit on your part.
God bless you.
aca


Jim Thomlinson Wrote:
On the sheet tab you want to react to the double click, right click th
tab
and select veiw code. This will take you to the VBE. Paste this code i
and
you are off and running...

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cance
As
Boolean)
Cancel = True
MsgBox Target.Address
End Sub
--
HTH...

Jim Thomlinson


"aca" wrote:


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

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



--
ac
-----------------------------------------------------------------------
aca's Profile: http://www.excelforum.com/member.php...fo&userid=2593
View this thread: http://www.excelforum.com/showthread.php?threadid=39305



All times are GMT +1. The time now is 07:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com