Setting shape transparency to 0 for a multiple shapes

RawlinsCross

Active Member
Joined
Sep 9, 2016
Messages
402
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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

RawlinsCross

Active Member
Joined
Sep 9, 2016
Messages
402
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

tonyyy

Well-known Member
Joined
Jun 24, 2015
Messages
1,784
Office Version
  1. 2010
Platform
  1. Windows
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,191,719
Messages
5,988,290
Members
440,148
Latest member
sandy123

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
Top