Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 181
Default Assign a text to a rectangle

I have a rectangle I made from the drawing tool bar and then I assigned a
macro to it... can I change the text of the rectangle based on the string
stored in a specific cell?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default Assign a text to a rectangle

Hi Alberto

Since it is an autoshape you need to use code to do that..Try the below.
Place this either in worksheet change event so that the text change will
happen as soon as the text is changed...

Dim sh As Shape
Set sh = ActiveSheet.Shapes("Rectangle 1")
sh.OLEFormat.Object.Text = Range("A1")

If this post helps click Yes
---------------
Jacob Skaria


"Alberto Ast" wrote:

I have a rectangle I made from the drawing tool bar and then I assigned a
macro to it... can I change the text of the rectangle based on the string
stored in a specific cell?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 181
Default Assign a text to a rectangle

I am not sure where you say to put it but I did put it in the macro where I
change the value of the cell and it works great
Thanks

"Jacob Skaria" wrote:

Hi Alberto

Since it is an autoshape you need to use code to do that..Try the below.
Place this either in worksheet change event so that the text change will
happen as soon as the text is changed...

Dim sh As Shape
Set sh = ActiveSheet.Shapes("Rectangle 1")
sh.OLEFormat.Object.Text = Range("A1")

If this post helps click Yes
---------------
Jacob Skaria


"Alberto Ast" wrote:

I have a rectangle I made from the drawing tool bar and then I assigned a
macro to it... can I change the text of the rectangle based on the string
stored in a specific cell?

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default Assign a text to a rectangle

Thanks for the feedback. Right click the sheet tabView code and paste the
below code and try changing the text in cell A1..The shape text will chage
with this...

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
Dim sh As Shape
Set sh = ActiveSheet.Shapes("Rectangle 1")
sh.OLEFormat.Object.Text = Range("A1")
End If
Application.EnableEvents = True
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Alberto Ast" wrote:

I am not sure where you say to put it but I did put it in the macro where I
change the value of the cell and it works great
Thanks

"Jacob Skaria" wrote:

Hi Alberto

Since it is an autoshape you need to use code to do that..Try the below.
Place this either in worksheet change event so that the text change will
happen as soon as the text is changed...

Dim sh As Shape
Set sh = ActiveSheet.Shapes("Rectangle 1")
sh.OLEFormat.Object.Text = Range("A1")

If this post helps click Yes
---------------
Jacob Skaria


"Alberto Ast" wrote:

I have a rectangle I made from the drawing tool bar and then I assigned a
macro to it... can I change the text of the rectangle based on the string
stored in a specific cell?

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 181
Default Assign a text to a rectangle

Yes but how will this work if the data and the rectangle are in different
sheets?

"Jacob Skaria" wrote:

Thanks for the feedback. Right click the sheet tabView code and paste the
below code and try changing the text in cell A1..The shape text will chage
with this...

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
Dim sh As Shape
Set sh = ActiveSheet.Shapes("Rectangle 1")
sh.OLEFormat.Object.Text = Range("A1")
End If
Application.EnableEvents = True
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Alberto Ast" wrote:

I am not sure where you say to put it but I did put it in the macro where I
change the value of the cell and it works great
Thanks

"Jacob Skaria" wrote:

Hi Alberto

Since it is an autoshape you need to use code to do that..Try the below.
Place this either in worksheet change event so that the text change will
happen as soon as the text is changed...

Dim sh As Shape
Set sh = ActiveSheet.Shapes("Rectangle 1")
sh.OLEFormat.Object.Text = Range("A1")

If this post helps click Yes
---------------
Jacob Skaria


"Alberto Ast" wrote:

I have a rectangle I made from the drawing tool bar and then I assigned a
macro to it... can I change the text of the rectangle based on the string
stored in a specific cell?



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default Assign a text to a rectangle

Hi Alberto

Right click the sheet tab where your data is and View codePaste the code..
Change the sheet name mentioend in the code...I assume the shape is in
Sheet3. and try changing the data..

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
Dim sh As Shape
Set sh = Worksheets("Sheet3").Shapes("Rectangle 1")
sh.OLEFormat.Object.Text = Range("A1")
End If
Application.EnableEvents = True
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Alberto Ast" wrote:

Yes but how will this work if the data and the rectangle are in different
sheets?

"Jacob Skaria" wrote:

Thanks for the feedback. Right click the sheet tabView code and paste the
below code and try changing the text in cell A1..The shape text will chage
with this...

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
Dim sh As Shape
Set sh = ActiveSheet.Shapes("Rectangle 1")
sh.OLEFormat.Object.Text = Range("A1")
End If
Application.EnableEvents = True
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Alberto Ast" wrote:

I am not sure where you say to put it but I did put it in the macro where I
change the value of the cell and it works great
Thanks

"Jacob Skaria" wrote:

Hi Alberto

Since it is an autoshape you need to use code to do that..Try the below.
Place this either in worksheet change event so that the text change will
happen as soon as the text is changed...

Dim sh As Shape
Set sh = ActiveSheet.Shapes("Rectangle 1")
sh.OLEFormat.Object.Text = Range("A1")

If this post helps click Yes
---------------
Jacob Skaria


"Alberto Ast" wrote:

I have a rectangle I made from the drawing tool bar and then I assigned a
macro to it... can I change the text of the rectangle based on the string
stored in a specific cell?

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
Text Box vs. rectangle, what is the difference? Tonso Excel Discussion (Misc queries) 1 April 8th 09 02:43 PM
how do i assign a value to a cell containing text Ani63 Excel Worksheet Functions 5 September 14th 06 08:41 PM
Assign a Value if Some of the Text in 2 Cells are the Same Blobbies Excel Discussion (Misc queries) 5 February 10th 06 02:02 AM
assign value to text shellie Excel Worksheet Functions 1 October 11th 05 04:46 PM
assign a value to text Galiant Excel Worksheet Functions 9 September 23rd 05 10:17 AM


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