Solved

Excel 2013 - iterate through selected Shapes

Posted on 2015-01-17
4
361 Views
Last Modified: 2015-01-22
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
Comment
Question by:hindersaliva
  • 2
4 Comments
 

Author Comment

by:hindersaliva
ID: 40555363
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
 
LVL 85

Assisted Solution

by:Rory Archibald
Rory Archibald earned 250 total points
ID: 40557245
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
 
LVL 11

Accepted Solution

by:
Jamie Garroch earned 250 total points
ID: 40557247
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
 

Author Closing Comment

by:hindersaliva
ID: 40564785
Thanks guys. I learned something new.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question