VBA to automatically add text to rectangle

george hart

Board Regular
Joined
Dec 4, 2008
Messages
241
Hi

I have a spreadsheet with numerous tabs that consist of graphs etc...Each tab currently has a rectangle with commentary that is manually entered.

My question then. Is there a way I can code the spreadsheet so that the rectangle automatically updates to capture certain text based on certain cells?

For example, I want a rectangle to read: Range("A1") & Range("B1") & "%" & " which shows a variance of " & Range("A3")

Thanks in advance
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Try

Code:
Sub test1()
ActiveSheet.Shapes("Rectangle 1").TextFrame.Characters.Text = Range("A1").Value & Range("B1").Value & "% which shows a variance of " & Range("A3").Value
End Sub
 
Upvote 0
Put a concatenation formula that returns what you want in a spare cell. Then link the text in the rectangle to that cell. To do that select your rectangle, go to the formula bar, type =, point at the cell with your mouse and press Enter.
 
Upvote 0

Forum statistics

Threads
1,215,903
Messages
6,127,651
Members
449,394
Latest member
fionalofthouse

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top