I am trying to find the max number using a loop. I do not want to use the application function. I want to use a loop, but can't figure it out. I have a reset button that generates 20 numbers out of 100 and a separate button that will output the max number out of the random 20 numbers. This is what i have so far.
Sub Button_Reset()
Dim i As Integer
Cells.Clear
For i = 1 To 20
Cells(i, 1) = Application.RandBetween(1, 100)
Next i
End Sub
Sub Button_Max()
Dim rng As Range
Dim max As Integer
Set rng = Range("1:20")
For i = 1 To 100
Next i
MsgBox ("The max is " & max & ".")
End Sub
Sub Button_Reset()
Dim i As Integer
Cells.Clear
For i = 1 To 20
Cells(i, 1) = Application.RandBetween(1, 100)
Next i
End Sub
Sub Button_Max()
Dim rng As Range
Dim max As Integer
Set rng = Range("1:20")
For i = 1 To 100
Next i
MsgBox ("The max is " & max & ".")
End Sub