View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default Prompting a macro to run on change of cell content

Hi
you may use an event procedure for this. e.g. the worksheet_change
event. See
http://www.cpearson.com/excel/events.htm
for more details


--
Regards
Frank Kabel
Frankfurt, Germany


I'm very new to VBA, but have had a bit of programming experience in
the past. I'm working with Excel 2000. What I want to do is
associate an imbedded image with each item in a drop down list so
that when an item is selected from the list the corresponding image
is displayed at a specified location. The way I have it set up is
with all images used being located in the same worksheet off of the
viewable/print area. When the macro runs, the apporpriate image is
copied and pasted to the specified cell. Here is what I have now.

Sub test()
'
' test Macro
' Macro created 4/14/2004 by x
'

'
If Range("C2") = Range("A2") Then
ActiveSheet.Shapes("Image1").Select
Selection.Copy
Range("B10").Select
ActiveSheet.Paste
End If
If Range("C2") = Range("A3") Then
ActiveSheet.Shapes("Image2").Select
Selection.Copy
Range("B10").Select
ActiveSheet.Paste
End If
If Range("C2") = Range("A4") Then
ActiveSheet.Shapes("Image3").Select
Selection.Copy
Range("B10").Select
ActiveSheet.Paste
End If
End Sub

Cell C2 contains the drop down menu with the range A2:A4 as the valid
data. Image1, Image2, and Image3 are embedded in the worksheet. The
code works fine when the macro is run, but it need the macro to run
automatically when a new selection is made - -ie, the macro needs to
run when the contents of cell C2 are changed- .

Any suggestions? Any other vital info I need to post that I have
neglected to mention? My thanks for any assistance or consideration
rendered!


---
Message posted from http://www.ExcelForum.com/