Hi guys,
I'm fairly new to VBA and I'm having a hard time with how Excel handles arrays. I'm generating a random number of integers from 1 to 10, iterating 10 times. I can't seem to figure out how to sum each iteration and place the value in a new array. Here's the code I have so far:
Any help would be appreciated.
I'm fairly new to VBA and I'm having a hard time with how Excel handles arrays. I'm generating a random number of integers from 1 to 10, iterating 10 times. I can't seem to figure out how to sum each iteration and place the value in a new array. Here's the code I have so far:
Code:
Sub getRandom()
Dim i As Integer, r As Integer
Dim minV As Integer, maxV As Integer
Dim size As Integer, iterate As Integer
Dim sumAll As Long
Dim myArray() As Variant
Cells.Clear
minV = 1200
maxV = 1800
size = 10
iterate = 10
For r = 1 To iterate
sumAll = 0
For i = 1 To size
ReDim Preserve myArray(1 To i)
myArray(i) = Int(((maxV - minV) + 1) * Rnd + minV)
Cells(i + 5, r) = myArray(i)
Next i
Next r
End Sub
Any help would be appreciated.