Excel: Add a Pop-up Picture to Multiple Cells

This page is an advertiser-supported excerpt of the book, Power Excel 2010-2013 from MrExcel - 567 Excel Mysteries Solved. If you like this topic, please consider buying the entire e-book.


Problem: I gave this book to my manager for Bosses' Day. He saw "œAdd a Pop-up Picture of an Item in a Cell," and wants you to add pictures to dozens of cells. Is there an easy way?

Strategy: Figure out how to map the item numbers in the worksheet to your folder of pictures. In this case, the pictures are stored in C:\qimage\. The file name is the letters "œQI", the part number, then "œ.jpg". You will have a different folder and likely a different prefix or suffix after the part number. Edit that line of the macro below.

  1. Open your workbook in Excel.
  2. Type Alt+F11 then Insert, Module.
  3. Enter these few lines of code in the VBA Editor.

    Sub AddABunch()

    For Each cell In Selection

    MyPic = "œC:\Qimage\QI" & cell.Value & "œ.jpg"

    With cell.AddComment

    .Shape.Fill.UserPicture MyPic

    .Shape.Height = 300

    .Shape.Width = 300

    End With

    Next cell

    End Sub

  4. Press Alt+Q to return to Excel.
  5. Select the dozens of cells where your manager wants pictures. Run the macro. Pictures will be added to all the cells in the selection.

Additional Details: For the complete guide to learning VBA, check out VBA & Macros for Microsoft Excel 2013 (ISBN 978-0789748614 ) from QUE Publishing.