View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
[email protected] PeterFauler@gmail.com is offline
external usenet poster
 
Posts: 4
Default I have a created a variable with a loop, how do I find average

that was defintiely helpful, how would you change it if you added a
second variable. look below at the example. it is incorrectly taking
scores from previous weeks. is there a way to clear the variable, once
it is captured


Sub rndgenandaver()
Dim score, t, lastt, averagescore, n, numberofweeks
t = 1
lastt = 16
n = 1
numberofweeks = 16
ReDim score(lastt, numberofweeks), averagescore(numberofweeks)
n = 1
For n = 1 To numberofweeks
t = 1
For t = 1 To lastt
If t 0 Then score(t, n) = Rnd()
Worksheets("Sheet1").Cells(t, n) = score(t, n)
Next t
averagescore(n) = Application.Average(score)
Worksheets("Sheet1").Cells(112, n) = averagescore(n)
Next n
End Sub