This works but I know it's the wrong way. What's the right way to do this? I think I need to cycle through an array as I need to repeat this code for many lines.
Public Orange As Long
Public Blue As Long
Public White As Long
Public Green As Long
Public Black As Long
Public Red As Long
Public onRadius As Single
Public offRadius As Single
Public offDash As Long
Public onSolid As Long
Public onWeight As Single
Public offWeight As Single
Public Sub LineDiagram()
Blue = RGB(79, 129, 189)
White = RGB(255, 255, 255)
Green = RGB(155, 187, 89)
Orange = RGB(247, 150, 70)
Black = RGB(0, 0, 0)
Red = RGB(192, 80, 77)
onRadius = 5
offRadius = 3
offDash = msoLineDash
onSolid = msoLineSolid
onWeight = 1
offWeight = 2
'------------------------------115 kV Line BD52------------------------------
Dim BD52State As String
BD52State = Range("BD52State")
Dim BD52Line As Object
Set BD52Line = ActiveSheet.Shapes.Range("BD52Line")
With BD52Line
If BD52State > 1 Then
With .Line
.DashStyle = onSolid
.ForeColor.RGB = Orange
.Weight = onWeight
End With
With .Glow
.Color.RGB = Black
.Radius = onRadius
End With
Else
With .Line
.DashStyle = offDash
.ForeColor.RGB = White
.Weight = offWeight
End With
With .Glow
.Color.RGB = Orange
.Radius = offRadius
End With
End If
End With
DoEvents
'------------------------------115 kV Line BX19------------------------------
Dim BX19State As String
BX19State = Range("BX19State")
Dim BX19Line As Object
Set BX19Line = ActiveSheet.Shapes.Range("BX19Line")
With BX19Line
If BX19State > 1 Then
With .Line
.DashStyle = onSolid
.ForeColor.RGB = Orange
.Weight = onWeight
End With
With .Glow
.Color.RGB = Black
.Radius = onRadius
End With
Else
With .Line
.DashStyle = offDash
.ForeColor.RGB = White
.Weight = offWeight
End With
With .Glow
.Color.RGB = Orange
.Radius = offRadius
End With
End If
End With
DoEvents
'------------------------------115 kV Line BX18------------------------------
Dim BX18State As String
BX18State = Range("BX18State")
Dim BX18Line As Object
Set BX18Line = ActiveSheet.Shapes.Range("BX18Line")
With BX18Line
If BX18State > 1 Then
With .Line
.DashStyle = onSolid
.ForeColor.RGB = Orange
.Weight = onWeight
End With
With .Glow
.Color.RGB = Black
.Radius = onRadius
End With
Else
With .Line
.DashStyle = offDash
.ForeColor.RGB = White
.Weight = offWeight
End With
With .Glow
.Color.RGB = Orange
.Radius = offRadius
End With
End If
End With
DoEvents
'------------------------------115 kV Line BE1------------------------------
Dim BE1State As String
BE1State = Range("BE1State")
Dim BE1Line As Object
Set BE1Line = ActiveSheet.Shapes.Range("BE1Line")
With BE1Line
If BE1State > 1 Then
With .Line
.DashStyle = onSolid
.ForeColor.RGB = Orange
.Weight = onWeight
End With
With .Glow
.Color.RGB = Black
.Radius = onRadius
End With
Else
With .Line
.DashStyle = offDash
.ForeColor.RGB = White
.Weight = offWeight
End With
With .Glow
.Color.RGB = Orange
.Radius = offRadius
End With
End If
End With
DoEvents
End Sub
Public Orange As Long
Public Blue As Long
Public White As Long
Public Green As Long
Public Black As Long
Public Red As Long
Public onRadius As Single
Public offRadius As Single
Public offDash As Long
Public onSolid As Long
Public onWeight As Single
Public offWeight As Single
Public Sub LineDiagram()
Blue = RGB(79, 129, 189)
White = RGB(255, 255, 255)
Green = RGB(155, 187, 89)
Orange = RGB(247, 150, 70)
Black = RGB(0, 0, 0)
Red = RGB(192, 80, 77)
onRadius = 5
offRadius = 3
offDash = msoLineDash
onSolid = msoLineSolid
onWeight = 1
offWeight = 2
'------------------------------115 kV Line BD52------------------------------
Dim BD52State As String
BD52State = Range("BD52State")
Dim BD52Line As Object
Set BD52Line = ActiveSheet.Shapes.Range("BD52Line")
With BD52Line
If BD52State > 1 Then
With .Line
.DashStyle = onSolid
.ForeColor.RGB = Orange
.Weight = onWeight
End With
With .Glow
.Color.RGB = Black
.Radius = onRadius
End With
Else
With .Line
.DashStyle = offDash
.ForeColor.RGB = White
.Weight = offWeight
End With
With .Glow
.Color.RGB = Orange
.Radius = offRadius
End With
End If
End With
DoEvents
'------------------------------115 kV Line BX19------------------------------
Dim BX19State As String
BX19State = Range("BX19State")
Dim BX19Line As Object
Set BX19Line = ActiveSheet.Shapes.Range("BX19Line")
With BX19Line
If BX19State > 1 Then
With .Line
.DashStyle = onSolid
.ForeColor.RGB = Orange
.Weight = onWeight
End With
With .Glow
.Color.RGB = Black
.Radius = onRadius
End With
Else
With .Line
.DashStyle = offDash
.ForeColor.RGB = White
.Weight = offWeight
End With
With .Glow
.Color.RGB = Orange
.Radius = offRadius
End With
End If
End With
DoEvents
'------------------------------115 kV Line BX18------------------------------
Dim BX18State As String
BX18State = Range("BX18State")
Dim BX18Line As Object
Set BX18Line = ActiveSheet.Shapes.Range("BX18Line")
With BX18Line
If BX18State > 1 Then
With .Line
.DashStyle = onSolid
.ForeColor.RGB = Orange
.Weight = onWeight
End With
With .Glow
.Color.RGB = Black
.Radius = onRadius
End With
Else
With .Line
.DashStyle = offDash
.ForeColor.RGB = White
.Weight = offWeight
End With
With .Glow
.Color.RGB = Orange
.Radius = offRadius
End With
End If
End With
DoEvents
'------------------------------115 kV Line BE1------------------------------
Dim BE1State As String
BE1State = Range("BE1State")
Dim BE1Line As Object
Set BE1Line = ActiveSheet.Shapes.Range("BE1Line")
With BE1Line
If BE1State > 1 Then
With .Line
.DashStyle = onSolid
.ForeColor.RGB = Orange
.Weight = onWeight
End With
With .Glow
.Color.RGB = Black
.Radius = onRadius
End With
Else
With .Line
.DashStyle = offDash
.ForeColor.RGB = White
.Weight = offWeight
End With
With .Glow
.Color.RGB = Orange
.Radius = offRadius
End With
End If
End With
DoEvents
End Sub