PC Review


Reply
Thread Tools Rate Thread

averaging non-contiguous data using arrays

 
 
Matt S
Guest
Posts: n/a
 
      2nd Jun 2009
All,

I have data that look like the following:

abc Top | bcd Top | Average | ST Dev | cde Top | def Top| Average|
St Dev
data | data | AV | STDEV | data | data |
AV | STDEV
data | data | AV | STDEV | data | data |
AV | STDEV
data | data | AV | STDEV | data | data |
AV | STDEV

What I'd like to do is make an overall average of abc, bcd, cde, and def
data. I am trying to make an array to first collect all the data together,
then make an array that is the average data to paste. Below is what I have
so far. I am running into trouble populating the overall array (arrTotAv)
and then also trying to get the average of that array (arrTotAvTop).

Any help would be appreciated!
Thanks!
Matt


'Average All files together
ActiveCell.Offset(0, 5).Value = "Total Average"
ActiveCell.Offset(0, 6).Value = "Total St Dev"
ActiveCell.Offset(0, 1).Select
ReDim arrTotAv(1 To 11, 1 To lngFileCount)
ReDim arrTotAvTop(1 To lngFileCount)

StartColumn = ActiveCell.Column
Count = 1

'Populate the array to average data
For j = 1 To StartColumn
If Not ActiveCell.Value = "" Then
If Mid(ActiveCell.Value, Len(ActiveCell.Value) - 2, 3) =
"Top" Then
arrTotAv(Count, 0) = ActiveCell.Range("A2:A12").Value
Count = Count + 1
Else: End If
Else: End If
ActiveCell.Offset(0, -1).Select
Next j

'Do average and st dev calculations on array
For j = 1 To 11
With Application.WorksheetFunction
arrTotAvTop(j) = .Average(.Index(arrTotAv, ?))
End With
Next j

'Paste Data into Sheet
ActiveCell.Offset(1, StartColumn + 3).Range("A1:A11").Value =
Application.Transpose(arrAvTop)
 
Reply With Quote
 
 
 
 
Matt S
Guest
Posts: n/a
 
      2nd Jun 2009
the table I tried to create didn't come out that great. Let me try again:

abcTop|bcd Top|Average|STDEV|cde Top|def Top|Average|STDEV
data | data | AV | SD | data | data | AV | SD
data | data | AV | SD | data | data | AV | SD
data | data | AV | SD | data | data | AV | SD


"Matt S" wrote:

> All,
>
> I have data that look like the following:
>
> abc Top | bcd Top | Average | ST Dev | cde Top | def Top| Average|
> St Dev
> data | data | AV | STDEV | data | data |
> AV | STDEV
> data | data | AV | STDEV | data | data |
> AV | STDEV
> data | data | AV | STDEV | data | data |
> AV | STDEV
>
> What I'd like to do is make an overall average of abc, bcd, cde, and def
> data. I am trying to make an array to first collect all the data together,
> then make an array that is the average data to paste. Below is what I have
> so far. I am running into trouble populating the overall array (arrTotAv)
> and then also trying to get the average of that array (arrTotAvTop).
>
> Any help would be appreciated!
> Thanks!
> Matt
>
>
> 'Average All files together
> ActiveCell.Offset(0, 5).Value = "Total Average"
> ActiveCell.Offset(0, 6).Value = "Total St Dev"
> ActiveCell.Offset(0, 1).Select
> ReDim arrTotAv(1 To 11, 1 To lngFileCount)
> ReDim arrTotAvTop(1 To lngFileCount)
>
> StartColumn = ActiveCell.Column
> Count = 1
>
> 'Populate the array to average data
> For j = 1 To StartColumn
> If Not ActiveCell.Value = "" Then
> If Mid(ActiveCell.Value, Len(ActiveCell.Value) - 2, 3) =
> "Top" Then
> arrTotAv(Count, 0) = ActiveCell.Range("A2:A12").Value
> Count = Count + 1
> Else: End If
> Else: End If
> ActiveCell.Offset(0, -1).Select
> Next j
>
> 'Do average and st dev calculations on array
> For j = 1 To 11
> With Application.WorksheetFunction
> arrTotAvTop(j) = .Average(.Index(arrTotAv, ?))
> End With
> Next j
>
> 'Paste Data into Sheet
> ActiveCell.Offset(1, StartColumn + 3).Range("A1:A11").Value =
> Application.Transpose(arrAvTop)

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Averaging many non-contiguous cells if they are blank Nadine Microsoft Excel Worksheet Functions 1 12th Apr 2010 11:25 PM
Declare Non-contiguous Columns as Arrays ward376 Microsoft Excel Programming 2 20th Mar 2009 07:57 PM
Building Non-Contiguous Arrays For Use With Linest Marston Microsoft Excel Worksheet Functions 4 19th May 2008 03:07 PM
Averaging non contiguous numbers ssg Microsoft Excel Misc 1 10th Dec 2007 03:22 AM
are arrays contiguous in memory? Peteroid Microsoft VC .NET 38 20th Dec 2005 11:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:24 AM.