How to hide/undie picture based on a cell A1=1/0? [Solved]

Report
-
Posts
2649
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
September 7, 2020
-
Hello,

can anyone help me how to hide/unhide picture 1?
if A1=0 then hide picture 1
if A1<>0 then show picture1

thanks

System Configuration: Windows / Edge 18.18362

1 reply

Posts
2649
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
September 7, 2020
437
Hi Chard,

I'm not sure if a picture itself can be hidden. You can however lock the picture to a row or column and then hide said row or column, when condition is met to "hide" the picture.

Locking a picture:
- Right-click picture
- Select "Size and Properties"
- Look for "Properties" and select "Move and Size with cells"

Now place the picture in (for this example) row 5 and make sure the picture doesn't overlap any other row to make it completely invisible.

Now we need to make row 5 hidden when A1=0 and show it again when A1<>0. To do that use the following code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub
If Target.Value = 0 And Target.Value <> vbNullString Then
    Rows(5).Hidden = True
Else
    Rows(5).Hidden = False
End If
End Sub


To implement the code, press Alt+F11 to open another window. Look at the left side of this window and find the sheet you are working on. Double click this sheet and paste the code in the big white field.

After doing this, place a 0 in A1 to see row 5, along with the picture, disappear. Clear the cell or enter another value and it will re-appear.

Let us know if any alterations are desired.

Best regards,
Trowa