+ Reply to Thread
Results 1 to 10 of 10

Show picture automatically base on value in cell

  1. #1
    Registered User
    Join Date
    12-07-2015
    Location
    Hanoi
    MS-Off Ver
    2010
    Posts
    14

    Show picture automatically base on value in cell

    Hi everybody,

    I have a folder store all employee's pictures. All pictures are named staff ID, for example: 123.jpg 456.jpg...
    Now, I would like to show employee picture automatically when I input a staff ID in cell.
    For instance: When I input 123 in cell D2, the employee picture 123.jpg will auto-show in the B2 area, something like that.

    Could you please give me the best way? Thank you so much.

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Show picture automatically base on value in cell

    Hi phan sang

    Here's one way...For test purposes, i inserted the Staff Id's in Column H and the corresponding Picture name in Col J.
    Put the code in the sheet module that contains your information.
    Right click on sheet tab, view code and paste in...
    As you enter the staff id in D2 it will look for the corresponding Pic associated with that Id in Range J and then attach the image stored in your path.
    Please Login or Register  to view this content.
    Last edited by sintek; 07-24-2017 at 04:16 AM.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Registered User
    Join Date
    12-07-2015
    Location
    Hanoi
    MS-Off Ver
    2010
    Posts
    14

    Re: Show picture automatically base on value in cell

    Hi sintek,

    I tried to run and edit your code but when running it shows the dialog below:
    1004.png

    After that, it highlighted yellow the line below:
    1004.png

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Show picture automatically base on value in cell

    You need to define the correct file path for your computer, I believe.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Show picture automatically base on value in cell

    As AliGW says...Have you changed this path to your path that the staff images are stored in...
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    12-07-2015
    Location
    Hanoi
    MS-Off Ver
    2010
    Posts
    14

    Re: Show picture automatically base on value in cell

    yes, my codes are now:

    Please Login or Register  to view this content.
    1004.png

    Could you please help me revise? Thank you so much.

  7. #7
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Show picture automatically base on value in cell

    Please upload a sample of your workbook...Where have you stored the staff Id's and staff Picture names... as per below code
    Please Login or Register  to view this content.

  8. #8
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Show picture automatically base on value in cell

    Hi,

    You have too many backslashes in the path that way. Change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    Note that because you are using a server location, you will end up with a linked picture this way, rather than an embedded one. If you need it to be embedded, you should use Shapes.AddPicture rather than Pictures.Insert which is actually deprecated.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  9. #9
    Registered User
    Join Date
    12-07-2015
    Location
    Hanoi
    MS-Off Ver
    2010
    Posts
    14

    Re: Show picture automatically base on value in cell

    Hi all,

    I tried changing Path like your instructions but it cannot.
    In cell D2, I used validation feature to list Staff ID in Sheet Employee List. In cell D2, I can press or choose Staff ID from list.
    Employee Pictures is being stored in the path: \\servername\EmployeePic$ with names: 123.jpg; 456.jpg, 789.jpg....

    1004.png

  10. #10
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Show picture automatically base on value in cell

    See post 7......

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Show picture by clicking on a cell
    By ossa in forum Excel General
    Replies: 13
    Last Post: 05-13-2015, 10:49 AM
  2. [SOLVED] Show picture of cell in Userform
    By bullshot25 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-09-2014, 04:06 AM
  3. Replies: 3
    Last Post: 06-02-2014, 08:04 AM
  4. Replies: 2
    Last Post: 03-31-2014, 01:32 AM
  5. [SOLVED] Macro to automatically change tab color to red base on a cell date
    By Chaunceycat in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-10-2012, 07:53 PM
  6. Displaying a picture base on cell content
    By Speclt in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-01-2010, 10:22 AM
  7. how to show different photos, base on different value of a cell?
    By Howard Hsu in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-25-2006, 03:00 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1