View Full Version : [SOLVED] UF Lookup Image Help

12-05-2013, 10:45 AM
I have a spreadsheet with 2 rows of data range("B3:Q4").
I have a Userform with an Image Control assigned to each cell in that range (No Image assigned).
Example ImgB3, ImgB4, ImgC3, ImgC4... etc.

The Userform has Images named "ImgDebbie", "ImgPeter", "ImgDennis".
These Images are not visible once userform starts.

What I need is for when userForm_Initialize starts.

I need something to look at the spreadsheet cell B3 and then if it says "Debbie"

I need Me.ImgB3.Picture = ImgDebbie.picture

And then have it look at cell B4 and do the same.

I believe I can possibly do this a very long way having each ImgB3-ImgQ4 test for the possible name and return image, but i would have a lot of code, since I would need to do it for each img.

I hope i was able to be clear on my situation.

Any help would be great.

12-05-2013, 10:57 AM
Will the values in the cells always match an image name (or be blank)?

12-05-2013, 10:59 AM
If it's blank then no image needed.

12-05-2013, 11:00 AM
Assuming they will:
for each cell in range("b3:q4").cells
if cell.value <> "" then me.controls("img" & cell.address(0,0)).picture = me.controls("img" & cell.value).picture
next cell

12-05-2013, 11:02 AM
Or even better can we set it up for if the cell is blank make linked img on userform visible = False ??

12-05-2013, 11:07 AM
Wow Aflatoon, you make it look so easy.

Thanks that worked perfectly.

12-05-2013, 11:12 AM
You're welcome. :)