Selecting sheets and shapes

ABabeNChrist
SilverLounger
Posts: 1868
Joined: 25 Jan 2010, 14:00
Location: Conroe, Texas

Selecting sheets and shapes

Post by ABabeNChrist »

How might I select more than 1 sheet and more than 1 shape at same time?
I was trying to use something like this a double array

Code: Select all

    With Sheets(Array("Cover Page", "Cover Page Texas")) _
    .Shapes.Range(Array("Rounded Rectangle 1", "Rectangle 5", "Rectangle 2")).Line
    End With
Last edited by ABabeNChrist on 25 Nov 2010, 02:57, edited 1 time in total.

User avatar
HansV
Administrator
Posts: 78542
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Selecting sheets and shapes

Post by HansV »

You cannot do that - Shapes is a property of a single Worksheet object, not of multiple worksheets.
You will have to loop through the sheets and loop through the shapes.
Best wishes,
Hans

ABabeNChrist
SilverLounger
Posts: 1868
Joined: 25 Jan 2010, 14:00
Location: Conroe, Texas

Re: Selecting sheets and shapes

Post by ABabeNChrist »

Thank you Hans
I was first working with only one sheet using

Code: Select all

    With Sheets("Cover Page").Shapes.Range(Array("Rounded Rectangle 1", _
                                                 "Rectangle 5")).Line
and it worked just fine
But when another sheet came into play, it then changed.

ABabeNChrist
SilverLounger
Posts: 1868
Joined: 25 Jan 2010, 14:00
Location: Conroe, Texas

Re: Selecting sheets and shapes

Post by ABabeNChrist »

As one might say “I’m stuck like chuck”
I have been trying to use a looping method with not much success. The only success I have had is spelling my worksheets correctly, which is not saying much.
Here is what my sad attempt looks like.

Code: Select all

Dim ws As Worksheet

    For Each ws In Worksheets

       ws.Range = Sheets("Cover Page", "Sheet2")

    Next ws
I attached a copy of sample workbook. This may help give you a better idea of what I am attempting.
I’m running all code through Userforms and Sheets may or may not be visible.
I used a name range for cells location that changes cell interior and Font and this part seems to works OK.
I also tried searching around the internet, looking to find some ideas, with not much success. :hairout:
Sample color.xlsm
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78542
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Selecting sheets and shapes

Post by HansV »

Sorry, it's not clear to me what I should look at.
Best wishes,
Hans

ABabeNChrist
SilverLounger
Posts: 1868
Joined: 25 Jan 2010, 14:00
Location: Conroe, Texas

Re: Selecting sheets and shapes

Post by ABabeNChrist »

Sorry for any confusion, I was unable to figure out how to loop my worksheets and shapes located on Cover Page and Sheet2 and I thought by showing you what I was working with might help. I’ve tried with not much luck.

User avatar
HansV
Administrator
Posts: 78542
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Selecting sheets and shapes

Post by HansV »

Yes, but you have four userforms. Which one of these should I look at, and more specifically, what part of the code behind that userform?
Best wishes,
Hans

ABabeNChrist
SilverLounger
Posts: 1868
Joined: 25 Jan 2010, 14:00
Location: Conroe, Texas

Re: Selecting sheets and shapes

Post by ABabeNChrist »

Userform ShapeColor and Glow are used for the shapes.
Userform ShapeColor is used for changing shape color lines and Userform Glow is used to change the color of glow.
Here is the code that I’m trying to change so that it can also include the shape line color on Sheet2, Rounded Rectangle 1.

Code: Select all

    With Worksheets("Cover Page").Shapes.Range(Array("Rounded Rectangle 1", "Rectangle 2")).Line
and this code to include shape glow color on Sheet2, Rounded Rectangle 1.

Code: Select all

    Set shpRange = Sheets("Cover Page").Shapes.Range(Array("Rounded Rectangle 1", "Rectangle 2"))

User avatar
HansV
Administrator
Posts: 78542
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Selecting sheets and shapes

Post by HansV »

I'd change the caption of CommandButton1 on the ShapeColor form to "Format Shape Color" instead of "Format Spape Color".

In the code behind the ShapeColor form, you have a block

Code: Select all

    With Worksheets("Cover Page").Shapes.Range(Array("Rounded Rectangle 1", "Rectangle 2")).Line
        ...
    End With
Duplicate this block and change the first line of the duplicate to

Code: Select all

    With Worksheets("Sheet2").Shapes.Range(Array("Rounded Rectangle 1")).Line
In the code behind the Glow form, you have a block

Code: Select all

    Set shpRange = Sheets("Cover Page").Shapes.Range(Array("Rounded Rectangle 1", "Rectangle 2"))

    With shpRange.Glow
        ...
    End With
Duplicate this block, and change the first line of the duplicate to

Code: Select all

    Set shpRange = Sheets("Sheet2").Shapes.Range(Array("Rounded Rectangle 1"))
Best wishes,
Hans

ABabeNChrist
SilverLounger
Posts: 1868
Joined: 25 Jan 2010, 14:00
Location: Conroe, Texas

Re: Selecting sheets and shapes

Post by ABabeNChrist »

That's all I had to do, I was trying all kind of things and getting no where.
Thank you so much Hans
As always, most greatly appreciated