Using mrhstn's code line from Messsage #2 as a base...Perhaps a stupid question, but what if I want to select the range that containers the largest value. Is it possible to somehow select a dimension?
You ask specifically for a for loop ...here's one ...as you request, the maximum is stored in the variable maxval ...How would you go about finding the maximum value in a column using a for loop?
I want to be able to store the maximum in a variable.
Sub for_loop_for_max()
Dim a, i As Long, maxval, maxcell As Long
a = Range("A1:A2000").Value
maxval = a(2, 1)
For i = 2 To 2000
If a(i, 1) > maxval Then
maxval = a(i, 1)
maxcell = i
End If
Next i
Range("A" & maxcell).Select
MsgBox maxval & " is the maximum at row " & maxcell
End Sub