Split creates a zero based array of strings.
That is why there are two commas before ALBUQUERQUE.
ALBUQUERQUE will be the third element in the array, but with the index of 2.
After you add the 11th row name, you will not need a comma following.
Const sList = ",,ALBUQUERQUE,BOSTON,BUFFALO,,,,"
Dim i As Long
Dim sArray() As String
sArray = Split(sList, ",")
For i = 2 To 11
If Range("AI" & i).Value > Range("AJ" & i).Value Then
ActiveSheet.Shapes.Range(Array(sArray(i))).Select
With Selection.ShapeRange.Fill
.ForeColor.RGB = RGB(0, 0, 255)
End With
Else
ActiveSheet.Shapes.Range(Array(sArray(i))).Select
With Selection.ShapeRange.Fill
.ForeColor.RGB = RGB(255, 0, 0)
End With
End If
Next i
I haven't tested it, but instead of:
ActiveSheet.Shapes.Range(Array(sArray(i))).Select
With Selection.ShapeRange.Fill
.ForeColor.RGB = RGB(0, 0, 255)
End With
Why not?
ActiveSheet.Shapes.Range(Array(sArray(i))).ShapeRange.Fill.ForeColor.RGB = RGB(0, 0, 255)
I'm unclear what the Array function is doing?
Bookmarks