Consulting

Results 1 to 7 of 7

Thread: UF Lookup Image Help

  1. #1
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location

    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.

  2. #2
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    Will the values in the cells always match an image name (or be blank)?
    Be as you wish to seem

  3. #3
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location
    If it's blank then no image needed.

  4. #4
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    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]
    Be as you wish to seem

  5. #5
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location
    Or even better can we set it up for if the cell is blank make linked img on userform visible = False ??

  6. #6
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location
    Wow Aflatoon, you make it look so easy.

    Thanks that worked perfectly.

  7. #7
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    You're welcome.
    Be as you wish to seem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •