VBA & Macro Problems

Enlarge an Excel Picture When Clicked With VBA

Bushra ParveenBushra Parveen Nov 22, 2026 868 views

Question details

The user wants an Excel picture to enlarge when clicked and return to its original size after a short delay.

How to Enlarge an Excel Picture When It Is Clicked
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet contains pictures that the user wants to preview at a larger size without permanently resizing them.
Observed behavior
The desired behavior is for a clicked picture to temporarily double in size and then return to its original dimensions.
Before you start

Open the workbook in desktop Excel and confirm that the pictures are individual worksheet shapes. Save the workbook as an Excel Macro-Enabled Workbook (.xlsm), and enable macros only if you trust the file.

Solution 1Recommended

Assign a VBA macro to each Excel picture

Use one macro to temporarily double the dimensions of any picture assigned to it.

Excel does not provide a simple mouse-over event for worksheet pictures. This click-based workaround identifies the clicked picture through Application.Caller, stores its dimensions, and restores them after a two-second delay.

1
Insert a VBA module

In desktop Excel, open the Developer tab and select Visual Basic. In the VBA editor, select Insert > Module.

2
Add the macro

Paste the following code into the module: Sub EnlargePicture() Dim pic As Shape Dim originalWidth As Double Dim originalHeight As Double Set pic = ActiveSheet.Shapes(Application.Caller) originalWidth = pic.Width originalHeight = pic.Height pic.Width = originalWidth * 2 pic.Height = originalHeight * 2 Application.Wait Now + TimeValue("00:00:02") pic.Width = originalWidth pic.Height = originalHeight End Sub

3
Assign the macro to a picture

Return to the worksheet, right-click a picture, select Assign Macro, choose EnlargePicture, and select OK. Repeat for each picture you want to enlarge.

4
Save and test

Save the .xlsm workbook, then click an assigned picture on the worksheet. It should double in size, pause for about two seconds, and return to its original dimensions.

Assign a VBA macro to each Excel picture
Allow room for the enlarged picture: A picture near the right or bottom edge of the visible worksheet may expand off-screen. Excel may be unresponsive during the short wait.
Free Microsoft Office alternative

Work with spreadsheet pictures in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for opening and editing Excel-format spreadsheets. Its format compatibility helps you move existing files into WPS, though this Excel-specific VBA workaround may not run in every WPS installation.

Insert and resize pictures in WPS Spreadsheets.Open and edit Microsoft Excel formats, including XLSX files.Use a familiar spreadsheet interface for an easier transition from Excel.Work with a free, lightweight office suite.
microsoft office alternative - wps office

Frequently Asked Questions

Can an Excel picture enlarge when I hover over it?

Excel does not provide a simple mouse-over event for worksheet pictures. Assigning a VBA macro through the picture's right-click menu provides a click-based alternative.

How do I change the enlargement time or size?

In Developer > Visual Basic, edit the macro's TimeValue("00:00:02") to change the delay. Change both multiplication factors from 2 to another value to adjust the enlargement.

Why doesn't clicking the picture run the macro?

Right-click the picture and check Assign Macro to confirm that EnlargePicture is selected. Also check whether Excel has disabled macros and enable them only if you trust the workbook.

Can I use the same macro for multiple pictures?

Yes. Right-click each picture, select Assign Macro, and choose EnlargePicture. Application.Caller identifies the picture that was clicked.

Can I run this VBA macro in Excel for the web?

No. Excel for the web cannot run VBA macros. Open the workbook in desktop Excel to assign and run the macro.