Hi Im trying to create a loop with an if function that reads data and then formats the colour of the cell depending on a result. I can get the loop to work from the starting point but it wont continue to loop throughout my whole table. Is there a way to resolve this?
Sub Loop
Range("G6:AM37").Interior.ColorIndex = 0 'No fill colour for all cells in the range to clear the last colouring
Dim ColRange As Range
For RR = 1 To 33 'Loop through Rows
For CC = 1 To 31 'Loop through col.
''''''''''''''''''''''''''''''''''''''''''
Dim MM As Variant
Set ColRange = Cells(RR + 5, CC + 6)
MM = Mid(ColRange, 9, 2)
If MM = "" Then
ColRange.Interior.ColorIndex = 0 ' no colour
Exit For
ElseIf CInt(MM) > 39 Then
ColRange.Interior.ColorIndex = 50
ElseIf CInt(MM) < 40 Then
ColRange.Interior.ColorIndex = 38
End If
''''''''''''''''''''''''''''''''''''''''''
Next
Next