Why bother with the
I don't really understand that line of code. Couldn't it just be
MyChange = Cells(MyLastRow,16)
At any rate, the following didn't give me any errors:
Sub DetermineRisk()
Dim i As Integer
Dim MyLastRow As Long
Dim MyVar As Double
Dim MyChange As Double
ThisWorkbook.Activate
For i = 4 To ActiveWorkbook.Worksheets.Count
With Sheets(i)
MyLastRow = Sheets(i).Cells(Sheets(i).Rows.Count, 16).End(xlUp).Row
MyVar = Sheets(i).Cells(MyLastRow, 16).Offset(-1, 0)
MyChange = Sheets(i).Cells(MyLastRow, 16).Offset(0, 0)
If Abs(MyVar) > 25000000 And Abs(MyChange) > 0.1 Then
Sheets(i).Tab.ColorIndex = 3
Else
Sheets(i).Tab.ColorIndex = 4
End If
End With
Next i
End Sub
Bookmarks