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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
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,143
Messages
6,123,279
Members
449,094
Latest member
GoToLeep

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