SOLVED

New Contributor

# Show images conditionally

I would like to show some images in my Excel spreadsheet only when certain conditions are valid.

For example: Only show the image when A1>10 or B4<5.

How should I do this?

Gosse

5 Replies

# Re: Show images conditionally

What kind of images? Have you looked at Conditional formatting?
best response confirmed by g.vanderveen (New Contributor)
Solution

Hi Gosse,

# Re: Show images conditionally

1. In C1 cell use =IF(AND(A1>10,B1<5),CHOOSE(RANDBETWEEN(1,3),"mb_1","mb_2","mb_3"),"x") this formula to generate "mb_1", "mb_2" and "mb_3" three images name based on your condition.

2. Select C1 cell and click on Formula | Define Name and type: "ShowPhoto" as name and =INDIRECT(Sheet1!\$C\$1) as refers to.

3. Insert 3 marble ball images into E11, F11, G11 and H11. And name these cells as "mb_1", "mb_2", "mb_3" and "x" and refers to as below:

For E11, =Sheet1!\$E\$11, For F11, =Sheet1!\$F\$11 For G11, =Sheet1!\$G\$11 For H11, =Sheet1!\$H\$11

4. Select E11 cell and Click on Home | Copy | Copy as picture. While a dialog box appear, Click on "Ok" to copy it. Now press Ctrl+V on that sheet to paste the image.

5. Select the pasted image and enter =ShowPhoto in the formula bar to link it.

6. Now change the value A1 or B1 to change the condition of C1 which will generate a image name and pasted image will change the image like below image:

Image: Changing the image based on condition

Here I have attached the whole working file. So that you can try it.

http://afaysal.blogspot.com/2017/05/how-to-display-image-in-worksheet-based.html

# RE: Show images conditionally

Thanx for your replies, it helps me a lot! The replies of Sergei Baklan and Faysal Al Farooqui are very similar, but the combination of both replies made me understand it even better. Thank you all very much.

# Re: Show images conditionally

Review this example that image added based on cell value :

In this template, when a cell in column A is selected, if there is picture of the cell contents is automatically shown on column F. The selected cell is also indicated by the arrow shape that we have created with VBA codes. Code snippet only was added to Worksheet_SelectionChange procedure for picture viewing.