Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 28
Default Assign Macro to a Cell

Is there a way to assign a macro to a cell such that clicking (or double
clicking) the cell executes the macro?
Thanks,
RUM

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 269
Default Assign Macro to a Cell

You can pick up either a selction change

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Row=1 and Target.Column=1 then
'do Stuff
End If
End Sub

a double click
Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, _
ByVal Target As Range, ByVal Cancel As Boolean)
If Target.Row=1 and Target.Column=1 then
'do Stuff
End If
End Sub

or a right click
Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, _
ByVal Target As Range, ByVal Cancel As Boolean)
If Target.Row=1 and Target.Column=1 then
'do Stuff
End If
End Sub

The code would go in VBA on the sheet where your target cell resides and not
a seperate module. Change the Target.Row=1 and Target.Column=1 to whatever
cell you desire.
--
If this helps, please remember to click yes.


"Bob Myers" wrote:

Is there a way to assign a macro to a cell such that clicking (or double
clicking) the cell executes the macro?
Thanks,
RUM

.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,836
Default Assign Macro to a Cell

You would probably learn a heck of a lot if you read this:
http://www.cpearson.com/excel/Events.aspx


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Paul C" wrote:

You can pick up either a selction change

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Row=1 and Target.Column=1 then
'do Stuff
End If
End Sub

a double click
Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, _
ByVal Target As Range, ByVal Cancel As Boolean)
If Target.Row=1 and Target.Column=1 then
'do Stuff
End If
End Sub

or a right click
Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, _
ByVal Target As Range, ByVal Cancel As Boolean)
If Target.Row=1 and Target.Column=1 then
'do Stuff
End If
End Sub

The code would go in VBA on the sheet where your target cell resides and not
a seperate module. Change the Target.Row=1 and Target.Column=1 to whatever
cell you desire.
--
If this helps, please remember to click yes.


"Bob Myers" wrote:

Is there a way to assign a macro to a cell such that clicking (or double
clicking) the cell executes the macro?
Thanks,
RUM

.

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
Formula or Macro to Assign Cell Locations econWGR Excel Discussion (Misc queries) 1 February 16th 07 02:57 AM
Assign F1 as a macro? Ryk Excel Discussion (Misc queries) 7 October 17th 06 01:12 AM
Assign Macro to tab superkopite Excel Discussion (Misc queries) 1 February 7th 06 09:42 PM
Assign Macro James Hamilton Excel Discussion (Misc queries) 2 November 2nd 05 10:56 PM
Un-assign a macro George Gee New Users to Excel 2 December 28th 04 05:44 PM


All times are GMT +1. The time now is 04:20 PM.

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

About Us

"It's about Microsoft Excel"