How to Make an Excel Picture Expand When Clicked Using VBA
Question details
The user wants to know how to make a small thumbnail image in Excel expand to a larger size when clicked by a user.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Creating interactive Excel dashboards or reports where users can click on small pictures to view them in full size without cluttering the spreadsheet.
- Observed behavior
- Excel does not have a native interactive 'click to enlarge' image feature, requiring a VBA macro workaround to toggle the picture size.
Ensure that the Developer tab is enabled in your Excel ribbon to insert and run a VBA macro. Remember to save your workbook as an Excel Macro-Enabled Workbook (.xlsm) to preserve your code.
Use a VBA Macro to Toggle Picture Size
Since Excel lacks a built-in feature to enlarge images on click, you can use a VBA macro assigned to the image to toggle its size between a small thumbnail and a larger view.
This method utilizes a VBA script that detects which specific image was clicked and multiplies its height, allowing you to use the exact same macro for multiple images in your workbook.
Go to the Insert tab, select Pictures, and place the image on your spreadsheet. Adjust it to the desired small thumbnail size.
Press Alt + F11 to open the Microsoft Visual Basic for Applications window. Click Insert > Module from the top menu.
In the new module window, write a Sub routine (e.g., Sub ResizePicture) that declares a Shape variable. Use ActiveSheet.Shapes(Application.Caller) to set the shape, and use an If statement to toggle the .Height property while setting .LockAspectRatio to msoCTrue.
Close the VBA editor and return to your spreadsheet. Right-click the picture you inserted, select Assign Macro, choose your ResizePicture macro from the list, and click OK.

Prevent Image Compression to Maintain Quality
When expanding images using a macro, they may appear blurry if Excel has compressed them. Disable compression in the workbook settings to ensure high-quality expansion.
Create Interactive Spreadsheets with Macros in WPS Office
WPS Office fully supports VBA macros, allowing you to create dynamic, interactive spreadsheets. You can easily write or import macros to make images expand on click, just like in Microsoft Excel, with an intuitive and familiar interface.
- 1. Enable Developer Tools: Open your workbook in WPS Spreadsheet and navigate to the Developer tab on the ribbon.
- 2. Access the VBA Editor: Click on 'Macros' or press Alt+F11 to access the built-in WPS Visual Basic Editor.
- 3. Insert the Code: Click Insert > Module, paste your image-resizing VBA code, and close the editor.
- 4. Assign and Test: Right-click your inserted picture, choose 'Assign Macro', select your script, and click the image to test the expansion.

Frequently Asked Questions
Can I make an Excel picture expand when hovering over it instead of clicking?
Excel does not natively support hover actions for images or shapes. Expanding an image requires an explicit click action tied to a VBA macro, as Excel does not trigger macros merely by mouse hover events.
Why does my expanded image look blurry in Excel?
This usually happens because Excel compresses images by default to reduce the overall file size. You can fix this by going to File > Options > Advanced, scrolling to 'Image Size and Quality', and checking 'Do not compress images in the file'.
Will the macro work if I send the Excel file to someone else?
Yes, as long as you save the file as a Macro-Enabled Workbook (.xlsm) and the recipient clicks 'Enable Content' or 'Enable Macros' when they open the file in their spreadsheet application.
How do I assign the same macro to multiple pictures without rewriting code?
You don't need to rewrite the code for each image. Because the suggested VBA script uses the 'Application.Caller' function, it automatically identifies exactly which image was clicked. Simply right-click each picture, select 'Assign Macro', and choose the same macro name.




