Hide all pictures in the selected cell range

Deepesh123

New Member
Joined
Mar 28, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi - Thanks in advance for your input. I need to hide all pictures for a selected range - for example - B6: P6 and then B9:P6 and unhide the same after few operations.

Also, i would like to hide a picture, text in next cell for a given cell range B3:B6 and unhide the same
 

Attachments

  • HideCard.PNG
    HideCard.PNG
    31.1 KB · Views: 4

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Check out these samples
VBA Code:
Sub HideAllPics()
    Dim pic As Picture
    Dim rng As Range
    Set rng = Range("B6:P6")
    For Each pic In ActiveSheet.Pictures

        If Not Application.Intersect(pic.TopLeftCell, Range(rng.Address)) Is Nothing Then
            pic.Visible = False
        End If
    Next
End Sub

Sub ShowAllPics()
    Dim pic As Picture
    Dim rng As Range
    Set rng = Range("B6:P6")
    For Each pic In ActiveSheet.Pictures

        If Not Application.Intersect(pic.TopLeftCell, Range(rng.Address)) Is Nothing Then
            pic.Visible = True
        End If
    Next
End Sub

Sub HideOnePics()
    Dim pic As Picture
    Dim rng As Range
    Set rng = Range("B6")
    For Each pic In ActiveSheet.Pictures

        If Not Application.Intersect(pic.TopLeftCell, Range(rng.Address)) Is Nothing Then
            pic.Visible = False
        End If
    Next
End Sub

Sub HideSomePics()
    Dim pic As Picture
    Dim rng As Range
    Set rng = Range("B6,E6,I6")
    For Each pic In ActiveSheet.Pictures

        If Not Application.Intersect(pic.TopLeftCell, Range(rng.Address)) Is Nothing Then
            pic.Visible = False
        End If
    Next
End Sub
 
Upvote 0
Dear Dave - Thanks for the reply. When i tried Hide All subroutine i get error-400. See attached picture. Thanks for your efforts.
 

Attachments

  • error.PNG
    error.PNG
    5.9 KB · Views: 2
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,583
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top