Using arrays

danblahut

New Member
Joined
Dec 1, 2015
Messages
1
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.:confused:

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
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,223,896
Messages
6,175,263
Members
452,627
Latest member
KitkatToby

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