Use onchange event to change text in an autoshape.

geodekl
06-24-2010, 11:31 AM
I've just been made responsible for maintaining a spreadsheet which has several autoshape callouts with text that has to be frequently updated. I've figured out how to use a macro to update the text, so what I'd like to do now is have an event that updates a specific autoshape whenever the value in a specific cell is changed. The problem is that I really don't know much about "onchange" events. Can anyone recommend a starting point for reading about them? What about other ways to accomplish the goal of linking the text of an autoshape to the value of a cell?

Here's an example of the code I'm using to change the text:
Sheets("SHAPE TESTS").Shapes("MTD_Callout").TextFrame.Characters.Text = Range("A1").Text


I need to figure out how to have that code fire whenever the value in cell A1 changes.

Thanks,

geodekl

CaBieberach
07-13-2010, 08:53 AM
Hi Geodelk

Try the following:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Worksheets("YourSheetName").Range("A1")) Is Nothing Then
Sheets("SHAPE TESTS").Shapes("MTD_Callout").TextFrame.Characters.Text = Worksheets("YourSheetName").Range("A1").Text
'
End If
'
End Sub
'
'NOTE: Replace "YoursheetName" with the sheet name you are using.


This is a good place to star reading about event handlers:
http://www.cpearson.com/excel/Events.aspx

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum