Setting shape transparency to 0 for a multiple shapes

RawlinsCross

Active Member
Joined
Sep 9, 2016
Messages
437
I want to turn 10 shapes (arrows and connecting lines) to .Transparency = 1 when a certain condition exists. There are 10 shapes named "CS_AC1".... though to ... "CS_AC10".

How do I cycle through them instead of listing each one separately:

Condition Then


Worksheets("Dashboard").Shapes.Range(Array("CS_AC1")).Select
Application.CommandBars("Format Object").Visible = False
With Selection.ShapeRange.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 0, 0)
.Transparency = 1
End With

Worksheets("Dashboard").Shapes.Range(Array("CS_AC2")).Select
Application.CommandBars("Format Object").Visible = False
With Selection.ShapeRange.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 0, 0)
.Transparency = 1
End With

Worksheets("Dashboard").Shapes.Range(Array("CS_AC3")).Select
Application.CommandBars("Format Object").Visible = False
With Selection.ShapeRange.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 0, 0)
.Transparency = 1
End With


..............etc.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Okay... found out I can clean it up.. but the selection command is still taking up a bit of time. Still don't know how to loop through these similarly named shapes. Code now is...

Condition Then

With Worksheets("Dashboard")
.Shapes.Range(Array("CS_AC1")).Select
Selection.ShapeRange.Line.Transparency = 1


.Shapes.Range(Array("CS_AC2")).Select
Selection.ShapeRange.Line.Transparency = 1


.Shapes.Range(Array("CS_AC3")).Select
Selection.ShapeRange.Line.Transparency = 1


.Shapes.Range(Array("CS_AC4")).Select
Selection.ShapeRange.Line.Transparency = 1


.Shapes.Range(Array("CS_AC5")).Select
Selection.ShapeRange.Line.Transparency = 1


.Shapes.Range(Array("CS_AC6")).Select
Selection.ShapeRange.Line.Transparency = 1


.Shapes.Range(Array("CS_AC7")).Select
Selection.ShapeRange.Line.Transparency = 1


.Shapes.Range(Array("CS_AC8")).Select
Selection.ShapeRange.Line.Transparency = 1


.Shapes.Range(Array("CS_AC9")).Select
Selection.ShapeRange.Line.Transparency = 1


.Shapes.Range(Array("CS_AC10")).Select
Selection.ShapeRange.Line.Transparency = 1


.Shapes.Range(Array("CS_AC11")).Select
Selection.ShapeRange.Line.Transparency = 1


.Shapes.Range(Array("CS_AC12")).Select
Selection.ShapeRange.Line.Transparency = 1


End With
 
Upvote 0
How 'bout...

Code:
Dim i As Long
With Worksheets("Dashboard")
    For i = 1 To 12
        .Shapes.Range(Array("CS_AC" & i)).ShapeRange.Line.Transparency = 1
    Next i
End With

Cheers,

tonyyy
 
Upvote 0

Forum statistics

Threads
1,214,897
Messages
6,122,148
Members
449,066
Latest member
Andyg666

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top