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

Solved/Closed
chard - Jun 16, 2020 at 07:15 PM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Jun 18, 2020 at 12:12 PM
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
Related:

1 response

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 555
Updated on Jul 23, 2020 at 11:26 AM
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

0