+ Reply to Thread
Results 1 to 6 of 6

Display Image Based on Cell Content

  1. #1
    Registered User
    Join Date
    11-19-2007
    Posts
    3

    Question Display Image Based on Cell Content

    Hi,

    I wish to display a picture on a spreadsheet that is derived from a Validated drop down list of values. eg. Apple, Banana, Pear etc. I have found some code to do this:-
    Please Login or Register  to view this content.
    This code works fine unless you have things like Command Buttons or CheckBox's on the same sheet. Excel includes them in Me.Pictures and proceeds to abend with a "type mismatch" error if you have any on the sheet.

    Does anyone know how to get around this?

    Regards

    Mark
    Last edited by Leith Ross; 11-19-2007 at 12:53 PM.

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Display Image Based on Cell Content

    I'd suggest something like this:

    First.....Start each picture name with "pic"...eg picBanana

    Then....Use the Worksheet_Change event:
    Please Login or Register  to view this content.
    Does that help?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Welcome to the Forum! As a member, you now have full access to the knowledge and posting tools that make this site unique.

    In order to provide you with prompt replies to your questions, there are a few rules we ask that you observe. Please remember to follow these rules when you post as a courtesy to your fellow members, and to those who are volunteering their time, and knowledge.

    Readability is key in getting a fast response to your question. You have many tools available to assist you in formatting your post. Any code you post, whether a worksheet formula or VBA code should be wrapped. You can find a list of other HTML format options in the forum rules.

    How to Wrap your Code
    On the Message window Toolbar you will see the # icon. Select the text you want to appear in a Code Window, and Click the # icon. This will wrap the code for you. You can also do this manually by placing the tag [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] at the end of the last line.

    You can read the Forum rules by clicking on the link below.
    Forum Rules
    If you have any questions, contact me by clicking on my name Leith Ross

    Sincerely,
    Leith Ross

  4. #4
    Registered User
    Join Date
    11-19-2007
    Posts
    3

    Hi

    I have tried the suggested code, but it fails on the procedure call. I think because it does not know about the "Target" specified. Where does this variable come from?


    Mark

  5. #5
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Display Image Based on Cell Content

    The Target is the current selection when the change occurs.

    When anything in the worksheet changes, the current selection (the Target) is passed to the Worksheet_Change event code. The code then checks if we are interested in those cells when they change.

    In the code I posted, it checks to see if the Target is cell F1.

    I attached a simple demo file (Of course, it contains macros)

    Please let us know if it helps.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    11-19-2007
    Posts
    3

    Smile

    This now works a treat.

    Many Thanks for the advice.

    Best Regards

    Mark

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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