-
UF Lookup Image Help
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.
-
Will the values in the cells always match an image name (or be blank)?
-
If it's blank then no image needed.
-
Assuming they will:
[vba]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[/vba]
-
Or even better can we set it up for if the cell is blank make linked img on userform visible = False ??
-
Wow Aflatoon, you make it look so easy.
Thanks that worked perfectly.
-
You're welcome.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules