Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default How to call a sub defined in macro when double click a cell?

Dear all,

I would like to know how to write the codes if I want to call a sub defined
in macro when double clicking a cell on the worksheet. I know that I can add
buttons on the worksheet, but I wonder if I can do the same thing by just
double clicking a cell.

I tried to record the macro, I got the following codes:

Range("A1").Select
ActiveCell.FormulaR1C1 = ""

Can anyone advise? Thanks a lot!

Ivan

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default How to call a sub defined in macro when double click a cell?

Say you want to run a macro called theMacro every time you double click
in cell A1. To do this you would use the sheet event BeforeDoubleClick.
Right click the sheet tab, select view code and paste the following
event code:

Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)
If Target.Address = "$A$1" Then
Call theMacro
End If
Cancel = True
End Sub

Hope this helps
Rowan

Ivan wrote:
Dear all,

I would like to know how to write the codes if I want to call a sub defined
in macro when double clicking a cell on the worksheet. I know that I can add
buttons on the worksheet, but I wonder if I can do the same thing by just
double clicking a cell.

I tried to record the macro, I got the following codes:

Range("A1").Select
ActiveCell.FormulaR1C1 = ""

Can anyone advise? Thanks a lot!

Ivan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default How to call a sub defined in macro when double click a cell?

Dear Rowan,

Thanks a lot! It helps!

Ivan

"Rowan Drummond" wrote:

Say you want to run a macro called theMacro every time you double click
in cell A1. To do this you would use the sheet event BeforeDoubleClick.
Right click the sheet tab, select view code and paste the following
event code:

Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)
If Target.Address = "$A$1" Then
Call theMacro
End If
Cancel = True
End Sub

Hope this helps
Rowan

Ivan wrote:
Dear all,

I would like to know how to write the codes if I want to call a sub defined
in macro when double clicking a cell on the worksheet. I know that I can add
buttons on the worksheet, but I wonder if I can do the same thing by just
double clicking a cell.

I tried to record the macro, I got the following codes:

Range("A1").Select
ActiveCell.FormulaR1C1 = ""

Can anyone advise? Thanks a lot!

Ivan


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default How to call a sub defined in macro when double click a cell?

You're welcome.

Ivan wrote:
Dear Rowan,

Thanks a lot! It helps!

Ivan

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Double Click within Cell James C. Excel Discussion (Misc queries) 0 April 23rd 09 01:17 AM
Double-click to run macro? JAnderson Excel Discussion (Misc queries) 6 February 8th 07 10:01 PM
Run macro on double click only famdamly Excel Discussion (Misc queries) 2 February 27th 06 12:15 PM
Click on graph bar to execute a double-click in a pivot table cell [email protected] Charts and Charting in Excel 4 August 3rd 05 01:37 AM
Call Userfor and click button with macro ExcelMonkey[_190_] Excel Programming 2 February 25th 05 04:41 PM


All times are GMT +1. The time now is 08:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"