excel vba Loop through all shapes on a sheet

The solution for “excel vba Loop through all shapes on a sheet” can be found here. The following code will assist you in solving the problem.

‘ —————————————————————-
‘ Purpose: Loop through all shapes on a sheet
‘ —————————————————————-
Sub loopShapesSheet()

Dim shp As Shape
Dim sh As Worksheet

Set sh = ThisWorkbook.Worksheets(“Shape1”)

‘If there is any shape on the sheet
If sh.Shapes.Count > 0 Then
‘Loop through all the shapes on the sheet
For Each shp In sh.Shapes

‘Print to immediate window shape type, shape name and sheet name holding the shape
‘Useful link: https://msdn.microsoft.com/en-us/VBA/Office-Shared-VBA/articles/msoshapetype-enumeration-office
Debug.Print shp.Type & vbTab & shp.Name & vbTab & shp.Parent.Name

Next shp
End If
End Sub

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

Similar Posts