How to auto change shape size based/dependent on specified cell value in Excel?
In Excel, shapes such as circles, rectangles, or custom graphics are commonly used for visual enhancement, dashboards, or data illustration. Sometimes, you may want a shape’s size to dynamically reflect the value in a certain cell—for instance, to create progress indicators, visual status displays, or to simply make your reports more interactive and intuitive. However, Excel does not provide a direct built-in feature to automatically link shape size with cell content. This article introduces practical methods to automatically resize shapes according to the value of a specified cell, helping you make your Excel projects more dynamic and visually meaningful.
Auto change shape size based on specified cell value with VBA code
To make a shape automatically adjust its size based on the value entered in a specific cell, you can utilize a VBA macro. This approach is especially effective if you want to automate dashboard elements or highlight changes in data visually without manually adjusting each shape. The following VBA code will link a shape’s size to a cell value in your worksheet.

Office Tab
Tabbed navigation for Word, Excel, PowerPoint, and more—just like a web browser, with smooth switching in one window.
Please follow these steps:
1. Right-click the sheet tab that contains the shape you want to resize, and select View Code from the context menu. This opens the code editor window for that particular worksheet.
2. In the Microsoft Visual Basic for Applications window, copy and paste the following VBA code into the Code window. Make sure that you paste it into the code sheet for the worksheet where your shape is located.
VBA code: Auto change shape size based on specified cell value in Excel
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Target.Row = 2 And Target.Column = 1 Then
Call SizeCircle("Oval 2", Val(Target.Value))
End If
End Sub
Sub SizeCircle(Name As String, Diameter)
Dim xCenterX As Single
Dim xCenterY As Single
Dim xCircle As Shape
Dim xDiameter As Single
On Error GoTo ExitSub
xDiameter = Diameter
If xDiameter > 10 Then xDiameter = 10
If xDiameter < 1 Then xDiameter = 1
Set xCircle = ActiveSheet.Shapes(Name)
With xCircle
xCenterX = .Left + (.Width / 2)
xCenterY = .Top + (.Height / 2)
.Width = Application.CentimetersToPoints(xDiameter)
.Height = Application.CentimetersToPoints(xDiameter)
.Left = xCenterX - (.Width / 2)
.Top = xCenterY - (.Height / 2)
End With
ExitSub:
End Sub Explanation and precautions:
- In this code, "Oval 2" refers to the name of the shape you intend to resize. Make sure this matches exactly the name shown in the Selection Pane (Home > Find & Select > Selection Pane).
- The code only triggers when a change is made specifically to cell A2 (which is Row 2, Column 1). If you wish to use a different cell, please update these values accordingly.
- The size of the shape is determined by the cell value, which represents the diameter in centimeters. The code sets an upper size limit of 10 cm and a lower limit of 1 cm to avoid extreme resizing issues.
- If you enter a value outside this range (less than 1 or greater than 10), the shape will be resized to the nearest limit.
- If the specified shape name cannot be found or the value is not a number, the code will ignore the action without generating an error prompt.
For scenarios where multiple shapes need to resize automatically based on values in different cells (for example, creating a series of visual indicators or gauges), you can extend the VBA solution as shown below.
VBA code: Auto resize multiple shapes based on different specified cells' value in Excel
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xAddress As String
On Error Resume Next
If Target.CountLarge = 1 Then
xAddress = Target.Address(0, 0)
If xAddress = "A1" Then
Call SizeCircle("Oval 1", Val(Target.Value))
ElseIf xAddress = "A2" Then
Call SizeCircle("Smiley Face 3", Val(Target.Value))
ElseIf xAddress = "A3" Then
Call SizeCircle("Heart 2", Val(Target.Value))
End If
End If
End Sub
Sub SizeCircle(Name As String, Diameter)
Dim xCenterX As Single
Dim xCenterY As Single
Dim xCircle As Shape
Dim xDiameter As Single
On Error GoTo ExitSub
xDiameter = Diameter
If xDiameter > 10 Then xDiameter = 10
If xDiameter < 1 Then xDiameter = 1
Set xCircle = ActiveSheet.Shapes(Name)
With xCircle
xCenterX = .Left + (.Width / 2)
xCenterY = .Top + (.Height / 2)
.Width = Application.CentimetersToPoints(xDiameter)
.Height = Application.CentimetersToPoints(xDiameter)
.Left = xCenterX - (.Width / 2)
.Top = xCenterY - (.Height / 2)
End With
ExitSub:
End Sub Important notes and usage tips:
If...ElseIf section before the End If. Enter the correct cell address and shape name as needed.3. After modifying and saving the code, press Alt + Q to close the Microsoft Visual Basic for Applications window and return to your worksheet.
Now, whenever you change the value in cell A2, the specified shape "Oval2" will be automatically resized in real time. See screenshot:

Similarly, if you update the values in cells A1, A2, or A3, the shapes "Oval 1", "Smiley Face 3", and "Heart 2" will adjust their sizes immediately based on their linked cells. See example below:

Additional reminders:
- The resizing only takes effect when values in the specified cells change. If you manually move or alter a shape in a way that disrupts its reference point, you may need to reset the shape position.
- Only numerical values will work as intended. Empty cells or text entries may cause the shape to reduce to the minimum size or not adjust as expected.
- Make sure macros are enabled in your Excel environment, as VBA solutions require macro permissions.
Note: The shape size adjustment stops increasing once the cell value exceeds 10 (set maximum 10 cm). Similarly, values below 1 will default to the minimum (1 cm).
Troubleshooting tips: If resizing does not work as expected, double-check that the shape names and cell references match exactly, macros are enabled, and there are no worksheet protection restrictions. If you encounter a run-time error, verify that the specified shapes exist on the active worksheet and their names are not misspelled.
Summary suggestion: The VBA method provides dynamic, real-time resizing and is ideal for interactive dashboards and data-driven reports. However, it requires user understanding of shape naming, VBA environment, and saving the workbook as a macro-enabled file (.xlsm) to preserve the code. This method is best for situations where automation is needed and workbook macro functionalities are acceptable.
Manual shape resizing via reference
If you only need to adjust shape sizes occasionally, or want a simple approach without using macros, you can manually set the shape size to match a cell value as needed. This approach is suitable when automation is not critical or where macro use is restricted.
Click the shape you want to resize, then in the Format Shape pane (right-click shape > Size and Properties), manually enter the width and height values. You can refer to your cell value for these inputs. While not automatic, this method is straightforward and effective for one-off adjustments.
Tip: With this approach, always ensure you manually update the shape size when cell values change, as there is no link between the shape and the cell. This method avoids security warnings from macros, but does not support real-time visual updates.
List and export all shapes in current Excel workbook:
The Export Graphics utility of Kutools for Excel helps you quickly list all shapes in the current workbook, and you can export all of them to a designated folder at once as shown in the screenshot below. Download and try it now! (30-day free trial)

Related articles:
- How to add mouse over tip to a certain shape in Excel?
- How to fill a shape with transparent background color in Excel?
- How to hide or unhide a certain shape based on specified cell value in Excel?
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
All Kutools add-ins. One installer
Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.
- All-in-one suite — Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
- One installer, one license — set up in minutes (MSI-ready)
- Works better together — streamlined productivity across Office apps
- 30-day full-featured trial — no registration, no credit card
- Best value — save vs buying individual add-in