MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Vlook up using pictures (bmp & jpg)


Posted by Roy Hernandez on January 01, 2002 6:14 PM

In a spreadsheet i have specific info about topic but would like to use vlook up to paste a picture automatically. How can i accomplish this besides having a spreadsheet on each topic and pasting each photo?


Posted by Damon Ostrander on January 01, 2002 11:02 PM

Hi Roy,

I assume that you mean that you have pictures stored in a worksheet and you want to do a lookup on the picture and copy and paste it somewhere else. This is easy to do. Simply put the name of the picture (Shape object) as a string into your lookup table. The VLOOKUP function will then yield the name of the picture. In VBA store this name into a string variable (e.g., strPicName), and then paste the picture from the source sheet (e.g., Sheet 2) to the desired destination sheet (e.g., Sheet 3) using code like this:

Sheets(2).Shapes(strPicName).Copy
Sheets(3).Paste

Happy computing.

Damon