Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 820
  • Last Modified:

Excel 2013 - iterate through selected Shapes

I have number of Shapes selected programmaticallly on a single sheet. Now I'd like to iterate through those Shapes. What would be a good way to do that?
0
hindersaliva
Asked:
hindersaliva
  • 2
2 Solutions
 
hindersalivaAuthor Commented:
I solved it by ...
Selection.Interior.Color = 192

I didn't need to iterate through the selected Shapes 'cos the above works. Seems pretty obvious!
0
 
Rory ArchibaldCommented:
Even though you don't need it, since you asked:

    Dim shp As Shape
    
    If TypeName(Selection) = "DrawingObjects" Then
        For Each shp In Selection.ShapeRange
            Debug.Print shp.Name
        Next shp
    End If

Open in new window

0
 
Jamie GarrochPowerPoint Consultant & DeveloperCommented:
Just to answer the original question (in case another reader need to know how to do this), you can loop through all shapes in a selection like this:

Sub CheckShapes()
  Dim oShp As Shape
  
  For Each oShp In ActiveWindow.Selection.ShapeRange
    Debug.Print oShp.Name
  Next
End Sub

Open in new window

0
 
hindersalivaAuthor Commented:
Thanks guys. I learned something new.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now