Resize an Excel Shape on Click Using VBA
Question details
The user wants to enlarge a picture-filled shape in Excel when clicked and restore its original size on the next click.
- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet contains shapes that should toggle between their original and enlarged dimensions when selected.
- Observed behavior
- Clicking an assigned shape should enlarge it, and clicking it again should restore its original dimensions.
Check that each shape's original height is greater than 25 and no more than 50 points for the threshold-based macro below. Save the workbook as an Excel Macro-Enabled Workbook (.xlsm) and enable macros only if you trust the file.
Assign a VBA toggle macro to each Excel shape
Use one macro to identify the clicked shape and toggle its height and width between their original and doubled sizes.
Application.Caller identifies the shape that started the macro. The 50-point threshold works when each shape's original height is greater than 25 and no more than 50 points; an enlarged shape will then be taller than 50 points.
In Excel, select Developer > Visual Basic, then choose Insert > Module.
Paste this code into the module: Sub AdjustShape() Dim shapeObject As Shape Dim change As Double Dim originalLock As MsoTriState Set shapeObject = ActiveSheet.Shapes(Application.Caller) If shapeObject.Height > 50 Then change = 0.5 Else change = 2 End If originalLock = shapeObject.LockAspectRatio shapeObject.LockAspectRatio = msoFalse shapeObject.Height = shapeObject.Height * change shapeObject.Width = shapeObject.Width * change shapeObject.LockAspectRatio = originalLock End Sub
Return to the worksheet, right-click a shape, select Assign Macro, choose AdjustShape, and select OK. Repeat for each shape you want to resize.
Click an assigned shape once to double its size, then click it again to restore its original height and width.

Work with spreadsheet shapes in WPS Office
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and Microsoft Office format compatibility for easier migration. You can work with shapes in WPS Spreadsheets, although this Excel VBA click-to-resize macro is specific to Excel and macro support may vary by WPS version.

Frequently Asked Questions
How does the macro know which shape I clicked?
After you assign the macro through the shape's right-click menu, Application.Caller returns the caller's name. ActiveSheet.Shapes(Application.Caller) uses that name to find the clicked shape.
Why does my shape shrink on the first click?
The example treats a height above 50 points as already enlarged. Check the shape's height and adjust the threshold or use a method that stores its original dimensions.
Do I need a separate macro for every shape?
No. Assign the same AdjustShape macro to each shape using right-click > Assign Macro. The macro uses Application.Caller to identify the shape that was clicked.
What file format should I use to keep the VBA code?
In Excel, choose File > Save As and select Excel Macro-Enabled Workbook (.xlsm). Enable macros when opening the file only if you trust its source.




