[Solved] Display a picture according to cell value?

  • Hello,

    I am going to produce an excel document which will allow the user to select a golfer from a list and view his details. I intend to use the "lookup" function to display the information but I do not know how to make his photograph appear in an adjacent cell. Having tried I don't believe it is possible for a cell value to "equal" a picture but hopefully someone can tell me how to solve my problem?

    I hope someone can help as this is extremely frustrating.

    Cheers, SeveJnr :wink2:

  • I just recorded the following macro code while pasting a picture on to an Excel sheet.

    ActiveSheet.Pictures.Insert("C:[fullpath to] Filename.JPG").Select
    Selection.ShapeRange.LockAspectRatio = msoTrue
    Selection.ShapeRange.Height = 288#
    Selection.ShapeRange.Width = 315.75
    Selection.ShapeRange.IncrementLeft 145.5
    Selection.ShapeRange.IncrementTop 18#

    This does not put the picture into a cell, but Top and Left increments should allow you to place it where you want on the sheet.

    You may want to use a change detection macro to trigger the paste (and the VLOOKUP updates) whenever the user changes the value in the player-name cell. I'd suggest using the CASE option for choosing the picture to paste, as it probably will run faster than a string of IF statements or some of the other logic options available in VBA.

    Hope this helps get you started.

  • Thanks for the quick response, you both gave me alternative ways to approach the problem which was great. I played around with a spreadsheet and finally got things to work as I planned but I have to thankyou for responding, without your advice I would still be button bashing!

    Cheers everyone, SeveJnr :biggrin:

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!