+ Reply to Thread
Results 1 to 22 of 22

Hide Or Show An Image Based On A Cell Value

  1. #1
    Registered User
    Join Date
    11-09-2007
    Posts
    66

    Hide Or Show An Image Based On A Cell Value

    I have a spreadsheet with two bitmap images inserted into it. In cell E2, I will enter a number, either a 1 or a 2. if I enter a 1, I want only the first image to be visible. If I enter a 2, I only want the second image to be visible. Is there a way to accomplish this (hopefully without the need for macros)? I've attached a spreadsheet as an example of what I'm trying to do. Also, note that I'd like the images to be stacked on top of each other so that they show up in the same place regardless of wether there's a 1 or a 2 in cell E5


    Any help is greatly appreciated.

    kc
    Attached Files Attached Files
    Last edited by kc27315; 03-31-2009 at 05:42 PM. Reason: more clarification

  2. #2
    Registered User
    Join Date
    11-09-2007
    Posts
    66

    re: Hide Or Show An Image Based On A Cell Value

    FYI, the two images were made using Insert/Object/Create from File, and then using a bitmap image I created in Microsoft Paint.

    kc

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    re: Hide Or Show An Image Based On A Cell Value

    To do exactly what you're asking would require code. For an alternative, see http://www.mcgimpsey.com/excel/lookuppics.html
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    11-09-2007
    Posts
    66

    Smile re: Hide Or Show An Image Based On A Cell Value

    Thank you so much. I guess I'll just have to bite the bullet and use code. I appreciate your help.

    kc
    Last edited by kc27315; 03-31-2009 at 06:22 PM. Reason: SOLVED

  5. #5
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    re: Hide Or Show An Image Based On A Cell Value

    Hi kc27315,

    You should consider changing the title of your thread to be more descriptive of your problem to help others searching for an answer to this (or a similar) issue - something like "Hide Or Show An Image Based On A Cell Value".

    That said, the only way I can think of doing this is via a Worksheet_Change macro which I've code on the attached. Note I've also included a data validation entry in cell E2 to help ensure the reliability of the macro.

    HTH

    Robert
    Attached Files Attached Files
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    re: Hide Or Show An Image Based On A Cell Value

    I like Trebor's suggestion, and am changing the title.

    Please take a little more time in composing thread titles, kc.

  7. #7
    Registered User
    Join Date
    04-01-2008
    Location
    Houston
    MS-Off Ver
    Office 365
    Posts
    85

    Re: Hide Or Show An Image Based On A Cell Value

    Here is a way to change a pic without a macro. Do they have to be bitmap images?


    Thanks,
    cullen
    Attached Files Attached Files

  8. #8
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Hide Or Show An Image Based On A Cell Value

    very clever , now how is that done?
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  9. #9
    Registered User
    Join Date
    04-01-2008
    Location
    Houston
    MS-Off Ver
    Office 365
    Posts
    85

    Re: Hide Or Show An Image Based On A Cell Value

    Sorry for not explaining in the original post.

    If you look at the workbook posted check the named ranges. In Sheet 2 you have your two images and the ranges "Newton" & "Einstein".

    when you select the image in the formula bar there was =Enbed("bitmap images","") (something like that i don't remember) but that has to be cleared out.

    On Sheet 1 on your image change the formula from above to =showmypic

    Behind the image i created a formula off of E2 in C6 =CHOOSE(E2,"Newton","Einstein")

    In your name manager create a range with a name "showmypic" in the formula =INDIRECT(Sheet1!$C$6)

    Hope this helps,
    Cullen

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Hide Or Show An Image Based On A Cell Value

    Very clever, Cullen, thanks.

  11. #11
    Forum Contributor
    Join Date
    03-11-2009
    Location
    duke's
    MS-Off Ver
    Excel 2007
    Posts
    112

    Re: Hide Or Show An Image Based On A Cell Value

    really nice idea MR. Cullen..but i didnt get excat idea. if i want to put more 5 photos how can i use? btw in sheet 2 u inserted picture and metioned name? once selte the photos in sheet2 its showing photos name. how did u mentioned there. even i tried add one more photo..but i didnt able to give name for this photo in sheet2.

    plz suggest me properly...

    thank u in advance and excuse for bothering u

  12. #12
    Registered User
    Join Date
    04-01-2008
    Location
    Houston
    MS-Off Ver
    Office 365
    Posts
    85

    Re: Hide Or Show An Image Based On A Cell Value

    Hi Raveepoojari,

    Once you have copied your pic to sheet two select the cells behind the pic and go to -- Insert-Name-Define -- and create a new range for your pic.

    In Sheet one you should only have to change the Choose formula to add the new named range.

    Thanks,
    Cullen

  13. #13
    Forum Contributor
    Join Date
    03-11-2009
    Location
    duke's
    MS-Off Ver
    Excel 2007
    Posts
    112

    Re: Hide Or Show An Image Based On A Cell Value

    really nice idea man..

    btw thank u

  14. #14
    Registered User
    Join Date
    04-04-2009
    Location
    Nashville, TN,USA
    MS-Off Ver
    Excel 2007
    Posts
    87

    Re: Hide Or Show An Image Based On A Cell Value

    This was just pure genious and has worked for me many times. However I am creating a new workbook on a different computer and after I print the page the pictures shrink down to little of nothing. It is getting very frustrating. Any thoughts on how to fix that?

  15. #15
    Registered User
    Join Date
    01-04-2011
    Location
    kl
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Hide Or Show An Image Based On A Cell Value

    Thank...really looking forward for this answer.

  16. #16
    Registered User
    Join Date
    11-17-2012
    Location
    Costa Rica
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Hide Or Show An Image Based On A Cell Value

    It's so simple once you understand how the method works!
    The =INDIRECT() formula was unkown to me, but seems to have many other useful applications.
    You sir have just changed the way I go about building spreadsheets.
    Thank you, I'm very impressed!

  17. #17
    Registered User
    Join Date
    01-04-2010
    Location
    Charlottetown, PE
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Hide Or Show An Image Based On A Cell Value

    I do not understand, I am unable to add a formula to the image itself, it mostly gives me only options to format the image.

  18. #18
    Registered User
    Join Date
    11-17-2012
    Location
    Costa Rica
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Hide Or Show An Image Based On A Cell Value

    To do that, you have to paste the image as linked picture. Then, when you select it, you should see the reference in the formula bar. You can paste the formula indicated previously there. Cheers!

  19. #19
    Registered User
    Join Date
    10-22-2020
    Location
    Philippines
    MS-Off Ver
    2016
    Posts
    1

    Re: Hide Or Show An Image Based On A Cell Value

    Thank u very much. I finally understand the steps.

  20. #20
    Registered User
    Join Date
    04-25-2023
    Location
    Brampton
    MS-Off Ver
    2208
    Posts
    1

    Re: Hide Or Show An Image Based On A Cell Value

    Hi,

    How would I show no image if the criteria is not met? I'm only able to switch between different images.

  21. #21
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Hide Or Show An Image Based On A Cell Value

    Quote Originally Posted by Prateeksha11 View Post
    Hi,

    How would I show no image if the criteria is not met? I'm only able to switch between different images.
    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  22. #22
    Registered User
    Join Date
    06-12-2023
    Location
    Cairo, Egypt
    MS-Off Ver
    2021
    Posts
    1

    Re: Hide Or Show An Image Based On A Cell Value

    in the active sheet you are working with, open VBA and paste the following code in the active sheet (e.g. sheet1):

    Please Login or Register  to view this content.
    This VBA code works even with gif and doesn't affect the size of the excel file.
    Last edited by AliGW; 06-12-2023 at 03:59 AM. Reason: Code tags added. Please read the forum rules.

+ 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