Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Attaching Macro to Cell instead of button?

Hello,
I have a cell that is a list. Instead of attaching a Macro to a button, I
would like it to run everytime a new selection from this list is selected. Is
this possible? If so, how?
Much thanks!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default Attaching Macro to Cell instead of button?

Yes, use the worksheet's _Change() event handler. To get there, choose the
sheet, right-click the name tab and choose [View Code] from the list. Copy
the code below and modify as needed (specifically, change the address to the
cell with your list, and either put the code to execute within the If...End
If statements, or if code already exists in a public module, then just call
that Sub from within the If ... End If statements.

Note that this will run even if someone chooses the same item in the list
over and over again, not just another choice from the list.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$D$2" Then
'code to execute here
MsgBox "D2 changed"
End If
End Sub


"Satchmo2006" wrote:

Hello,
I have a cell that is a list. Instead of attaching a Macro to a button, I
would like it to run everytime a new selection from this list is selected. Is
this possible? If so, how?
Much thanks!

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Attaching Macro to Cell instead of button?

On 29 aug, 22:36, Satchmo2006
wrote:
Hello,
I have a cell that is a list. Instead of attaching a Macro to a button, I
would like it to run everytime a new selection from this list is selected. Is
this possible? If so, how?
Much thanks!


You mean something like this ??
example macro xx reacts to changes on sheet 1

Sub xx()
Range("c1").Value = Range("a1").Value * Range("b1").Value
End Sub

groeten. Hans


(click on tab view code . in top line the following)
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
xx
End Sub

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
Attaching an image to a cell jrr41 Excel Discussion (Misc queries) 2 July 17th 07 11:05 PM
Need help with recording a macro, attaching a button oxicottin Excel Worksheet Functions 9 January 18th 07 05:20 PM
Inserting a button into a cell and linking it to a macro Robb W Excel Discussion (Misc queries) 3 May 2nd 06 09:04 PM
Attaching a macro to a VB button on a form WildGlio Excel Worksheet Functions 2 March 25th 05 11:11 PM
Attaching a particular user defined function to cust button Ajay Excel Discussion (Misc queries) 3 February 23rd 05 08:29 AM


All times are GMT +1. The time now is 02:33 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"