This is my code
Sub lab1()
Dim first As Integer
Dim third As Integer
Dim total As Integer
total = 0
For i = 0 To i = 99
first = Application.WorksheetFunction.RandBetween(1, 100)
total = total + first
Next i
MsgBox (total)
End Sub
I am trying to generate 100 random numbers between 1 to 100 and store each number into the variable ‘total’. I cant understand why the value of total is always like below 100 , it seems like that ‘total’ is only storing 1 random number not 100 random number
For i = 0 To 99 << this is an important line to notice