Solved

Excel 2013 - iterate through selected Shapes

Posted on 2015-01-17
4
468 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 12

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

636 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