LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA Calculation with Variables


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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Calculation with Variables Hawk Excel Programming 1 March 25th 10 11:39 PM
Not at all clear on use of variables and/or object variables JMay-Rke Excel Discussion (Misc queries) 11 July 4th 08 06:36 PM
Storing variables in a macro and using those variables to performcalculations. [email protected] Excel Programming 3 December 10th 07 04:13 PM
Automating Calculation of Lagged Cross Correlations between Variables [email protected] Excel Programming 1 September 3rd 07 10:51 PM
Using Two Variables in Excel Calculation VBA Rita Excel Programming 1 September 26th 06 07:49 PM


All times are GMT +1. The time now is 04:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"