J
Jenn
I am trying some exercises on how to do loops since I am new at coding. I have practiced with the following one. What I would like to do is instead of saying for rows 1 -15 I want it to be dynamic to perform the code until the end on the values in the column (lets assume someone adds a value in row 16, the code below would not evalute row 16). Thanks in advance...
Sub ExitForDemo()
Dim MaxVal As Double
Dim Row As Long
Dim TheCell As Range
MaxVal = Application.WorksheetFunction.Max(Range("A:A"))
For Row = 1 To 15
Set TheCell = Range("A1").Offset(Row - 1, 0)
If TheCell.Value = MaxVal Then
MsgBox "Max Value is in Row " & Row & " Equals " & TheCell.Value
TheCell.Activate
Exit For
End If
Next Row
End Sub
Sub ExitForDemo()
Dim MaxVal As Double
Dim Row As Long
Dim TheCell As Range
MaxVal = Application.WorksheetFunction.Max(Range("A:A"))
For Row = 1 To 15
Set TheCell = Range("A1").Offset(Row - 1, 0)
If TheCell.Value = MaxVal Then
MsgBox "Max Value is in Row " & Row & " Equals " & TheCell.Value
TheCell.Activate
Exit For
End If
Next Row
End Sub