Multiple Worksheet Changes in One Worksheet

Jknoll1122

New Member
Joined
Feb 9, 2021
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I have many shapes (78) that I need to change the size of when a cell value is changed. The following code works to change one shape but I'm struggling to get it to work with more than one shape.

Private Sub Worksheet_Change(ByVal Target As Range)

Dim myRect As Rectangle

If Intersect(Target, Me.Range("l12:m13")) Is Nothing Then Exit Sub

Set myRect = Me.Rectangles("rectangle 8")

With myRect

.Width = Me.Range("l12").Value

.Height = Me.Range("m12").Value

End With

End Sub

How can I duplicate this code to apply to multiple shapes? This code also requires you to select the cell and enter a value before the shape changes. I would like the shape to change size as soon as the value is changed (cell value is a formula). Any help on this would be appreciated.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Welcome to the Forum!

If the cell changes are formula-driven, you'll need to use the Worksheet_Calculate event (or a Worksheet_Change on the precedent cells).

How are your shapes named? And how do they correspond to the cells that determine width and height? (Ideally we'll be able to loop through shape names and cells in an orderly fashion)
 
Upvote 0
Welcome to the Forum!

If the cell changes are formula-driven, you'll need to use the Worksheet_Calculate event (or a Worksheet_Change on the precedent cells).

How are your shapes named? And how do they correspond to the cells that determine width and height? (Ideally we'll be able to loop through shape names and cells in an orderly fashion)
The shapes are all named "Rectangle1", "Rectangle 2", etc.

Shape "Rectangle 8" currently works with the above code for example. When cell L12 increases in value, the shape's width increases. When M12 increase in value, the shape's height increases. I really only care about the width. The height value will never change.
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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