Hiya,
I've got a Sub that goes through ranges and colors in the cells depending on the value. In the 3rd part of the Sub, I use an array to see if values exist in column "M" and if they do then colour in the corresponding cell in "N." At the moment, it's coloring in cells in a different range (I think it's starting from row 1 not row 14 which is where it should start). I'm new to using arrays so can someone help please?
Can anyone suggest where I'm going wrong?
I've got a Sub that goes through ranges and colors in the cells depending on the value. In the 3rd part of the Sub, I use an array to see if values exist in column "M" and if they do then colour in the corresponding cell in "N." At the moment, it's coloring in cells in a different range (I think it's starting from row 1 not row 14 which is where it should start). I'm new to using arrays so can someone help please?
Code:
Public Sub ColorMeIn()
Dim LastRow As Long
Set LastCell = Range("A1").SpecialCells(xlCellTypeLastCell)
LastRow = LastCell.Row
Dim MyRange As String
Dim r As Variant
Dim cl As Object
Dim Arr() As Variant
MyRange = "M14:M" & LastRow
'Set up an array in this range and search for condition, evaluation to true results in colorindex in
'corresponding cells in row "N" being set to 2 (WHITE background)
Arr() = Range(MyRange)
For i = LBound(Arr()) To UBound(Arr())
If Arr(i, 1) = "END USER PACK SIZE CONVERSION!" Then
Range("N" & i).Interior.ColorIndex = 2
End If
Next i
End Sub
Can anyone suggest where I'm going wrong?