I was asked a few days ago if it is possible to lookup a picture in Excel. The scenario was that they wanted to be able to type in a code, and for Excel to return the picture of that product.
I created a simple picture lookup spreadsheet with a small amount of VBA. A button is used to run the macro that performs the picture lookup.
Download the picture lookup spreadsheet.
Create a Macro to Lookup a Picture in Excel
Each picture in the spreadsheet has been assigned a name which is used to identify the picture. The picture the user wants to find is entered in cell A2.
The VBA used for the macro can be seen below;
Sub Show_Picture()
Dim app_pic As Picture
Worksheets("Sheet1").Pictures.Visible = False
For Each app_pic In Worksheets("Sheet1").Pictures
If app_pic.Name = Range("A2").Text Then
app_pic.Visible = True
Exit For
End If
Next app_pic
End Sub
Leave a Reply