Monday, June 15, 2015

Hide / delete all shapes/pictures falling on particular range in sheet

Hi Friends

Many time you need to clear all unwanted shapes from particular range by deleting or hiding, and since shapes/ pictures doesn't reside in cells but floats above it which makes it difficult to manage, we can use following code to manage floating shop per our need:

Sub Hide_Shapes()

Dim s As String

Dim sObject As Shape

Dim rng As Range

Set ws = ActiveSheet

'Set ws = ActiveWorkbook.Worksheets("Sheet1")

Set rng = ws.Range("A:C,BC:BD")

For Each sObject In ws.Shapes

With sObject

s = .TopLeftCell.Address & ":" & .BottomRightCell.Address

End With

If Not Intersect(rng, ws.Range(s)) Is Nothing Then

sObject.Visible = msoFalse

'use below line for deleting shape


End If


End Sub

Do let me update your views,