Please appreciate if you can help me clarify a doubt.
In this procedure to find the max value in a range, why is Row -1 and not just Row? Thank you.
Sub ExitForDemo()
Dim MaxVal As Double
Dim Row As Long
MaxVal = WorksheetFunction.Max(Range("A:A"))
For Row = 1 To Rows.Count
If Range("A1").Offset(Row - 1, 0).Value = MaxVal Then
Range("A1").Offset(Row - 1, 0).Activate
MsgBox "Max Value is in Row " & Row
Exit For
End If
Next Row
End Sub
In this procedure to find the max value in a range, why is Row -1 and not just Row? Thank you.
Sub ExitForDemo()
Dim MaxVal As Double
Dim Row As Long
MaxVal = WorksheetFunction.Max(Range("A:A"))
For Row = 1 To Rows.Count
If Range("A1").Offset(Row - 1, 0).Value = MaxVal Then
Range("A1").Offset(Row - 1, 0).Activate
MsgBox "Max Value is in Row " & Row
Exit For
End If
Next Row
End Sub