Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I would like to see the code that puts the data into the array. I could fix the code you posted but it is better to fix the entire code. there are either tow ways of handling an array of scores that may have diffferent lengths. 1) Put the scores into an array containing the exact length of rounds of golf played using REDIM Suppose the scores are in a spreadsheet like this A B C D E F G Bob 72 82 80 92 100 85 **** 82 92 85 Bob 72 90 Dim Scores() as variant LastRow = Range("A" & rows.count).end(xlup).Row for Rowcount = 2 to LastRow ColCount = 2 Index = 0 Do while Cells(RowCount,ColCount) < "" Redim Scores(0 to Index) Scores(0) = Cells(RowCount,Colcount) ColCount = Colcount + 1 Index = Index + 1 loop next RowCount Now the average would be simply Average = WorksheetFunction.Average(Scores) I know I've simplified the problems and didn't include using the best scores but I was just trying to show different methods. 2) Use a multi-dimension array and add a column to the array which contains the number of round of golf a person has played. Then average the number of rounds of golf a person have played using the following Worksheet.function.Sum(Scores)/RoundsPlayed Since you have in the array zeroes if less than 10 rounds werre played. -- joel ------------------------------------------------------------------------ joel's Profile: 229 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=190745 http://www.thecodecage.com/forumz |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
VBA Calculation with Variables | Excel Programming | |||
Not at all clear on use of variables and/or object variables | Excel Discussion (Misc queries) | |||
Storing variables in a macro and using those variables to performcalculations. | Excel Programming | |||
Automating Calculation of Lagged Cross Correlations between Variables | Excel Programming | |||
Using Two Variables in Excel Calculation VBA | Excel Programming |