PC Review


Reply
Thread Tools Rate Thread

AVERAGE of the previous meaningful cells

 
 
Gilbert De Ceulaer
Guest
Posts: n/a
 
      26th Feb 2006
B10 = AVERAGE(A1:A10),
B11 = AVERAGE(A2:A11), etc.

In case there are empty cells in the A-column, the result is not correct
anymore because AVERAGE does not take en empty cell into account.
For instance if A1:A10 are 1, A11:A20 are empty and A21:A30 are 2, the above
formula in B21 would give AVERAGE(A12:A21), or 2.

What I want is the average of the previous 10 meaningful cells so - in this
case - the average of A2:A10 and A21, or (9*1+2)/10 = 1.1

Question : Is there a possibility to calculate the average of the previous
10 meaningful cells (0 is meaningful, blank is not)

Thanks in advance.
Gilbert



 
Reply With Quote
 
 
 
 
Bernard Liengme
Guest
Posts: n/a
 
      26th Feb 2006
Hi Gilbert,
I found it difficult to think 'backwards' with Excel function so I did it in
VBA
With =myavg(A21) this gives 1.1 for your data

Function myAvg(mystart)
Application.Volatile

Set mycell = mystart
mysum = 0#
mycount = 0#
Do While mycount < 10
If Application.WorksheetFunction.IsNumber(mycell.Value) Then
mysum = mysum + mycell.Value
mycount = mycount + 1
End If
Set mycell = mycell.Offset(-1, 0)
Loop
myAvg = mysum / 10#

End Function

best wishes
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"Gilbert De Ceulaer" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> B10 = AVERAGE(A1:A10),
> B11 = AVERAGE(A2:A11), etc.
>
> In case there are empty cells in the A-column, the result is not correct
> anymore because AVERAGE does not take en empty cell into account.
> For instance if A1:A10 are 1, A11:A20 are empty and A21:A30 are 2, the
> above formula in B21 would give AVERAGE(A12:A21), or 2.
>
> What I want is the average of the previous 10 meaningful cells so - in
> this case - the average of A2:A10 and A21, or (9*1+2)/10 = 1.1
>
> Question : Is there a possibility to calculate the average of the previous
> 10 meaningful cells (0 is meaningful, blank is not)
>
> Thanks in advance.
> Gilbert
>
>
>



 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      26th Feb 2006
Try this in B10

=AVERAGE(LARGE(IF(A$1:A10<>"",A$1:A10),ROW(INDIRECT("1:10"))))

which is an array formula, it should be committed with Ctrl-Shift-Enter, not
just Enter. Copy down.

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Gilbert De Ceulaer" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> B10 = AVERAGE(A1:A10),
> B11 = AVERAGE(A2:A11), etc.
>
> In case there are empty cells in the A-column, the result is not correct
> anymore because AVERAGE does not take en empty cell into account.
> For instance if A1:A10 are 1, A11:A20 are empty and A21:A30 are 2, the

above
> formula in B21 would give AVERAGE(A12:A21), or 2.
>
> What I want is the average of the previous 10 meaningful cells so - in

this
> case - the average of A2:A10 and A21, or (9*1+2)/10 = 1.1
>
> Question : Is there a possibility to calculate the average of the previous
> 10 meaningful cells (0 is meaningful, blank is not)
>
> Thanks in advance.
> Gilbert
>
>
>



 
Reply With Quote
 
Bernard Liengme
Guest
Posts: n/a
 
      26th Feb 2006
Not sure this works.
If data in A is 99, 99,99 99, 1,1,1,1,1,1, <10 blanks>,
2,2,2,2,2,2,2,2,2,2,2,
Value from formula after B20 are not correct because of the LARGE function.
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"Bob Phillips" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Try this in B10
>
> =AVERAGE(LARGE(IF(A$1:A10<>"",A$1:A10),ROW(INDIRECT("1:10"))))
>
> which is an array formula, it should be committed with Ctrl-Shift-Enter,
> not
> just Enter. Copy down.
>
> --
>
> HTH
>
> Bob Phillips
>
> (remove nothere from the email address if mailing direct)
>
> "Gilbert De Ceulaer" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
>> B10 = AVERAGE(A1:A10),
>> B11 = AVERAGE(A2:A11), etc.
>>
>> In case there are empty cells in the A-column, the result is not correct
>> anymore because AVERAGE does not take en empty cell into account.
>> For instance if A1:A10 are 1, A11:A20 are empty and A21:A30 are 2, the

> above
>> formula in B21 would give AVERAGE(A12:A21), or 2.
>>
>> What I want is the average of the previous 10 meaningful cells so - in

> this
>> case - the average of A2:A10 and A21, or (9*1+2)/10 = 1.1
>>
>> Question : Is there a possibility to calculate the average of the
>> previous
>> 10 meaningful cells (0 is meaningful, blank is not)
>>
>> Thanks in advance.
>> Gilbert
>>
>>
>>

>
>



 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      26th Feb 2006
You're right, shouldn't have relied on the OP's data.

Maybe this is better

=SUM(SUBTOTAL(9,OFFSET($A$1,LARGE(IF($A$1:$A10<>"",ROW($A$1:$A10)),ROW(INDIR
ECT("1:10")))-1,0)))/MIN(COUNT($A$1:$A10),10)

which is an array formula, it should be committed with Ctrl-Shift-Enter, not
just Enter.

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Bernard Liengme" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Not sure this works.
> If data in A is 99, 99,99 99, 1,1,1,1,1,1, <10 blanks>,
> 2,2,2,2,2,2,2,2,2,2,2,
> Value from formula after B20 are not correct because of the LARGE

function.
> --
> Bernard V Liengme
> www.stfx.ca/people/bliengme
> remove caps from email
>
> "Bob Phillips" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Try this in B10
> >
> > =AVERAGE(LARGE(IF(A$1:A10<>"",A$1:A10),ROW(INDIRECT("1:10"))))
> >
> > which is an array formula, it should be committed with Ctrl-Shift-Enter,
> > not
> > just Enter. Copy down.
> >
> > --
> >
> > HTH
> >
> > Bob Phillips
> >
> > (remove nothere from the email address if mailing direct)
> >
> > "Gilbert De Ceulaer" <(E-Mail Removed)> wrote in message
> > news:#(E-Mail Removed)...
> >> B10 = AVERAGE(A1:A10),
> >> B11 = AVERAGE(A2:A11), etc.
> >>
> >> In case there are empty cells in the A-column, the result is not

correct
> >> anymore because AVERAGE does not take en empty cell into account.
> >> For instance if A1:A10 are 1, A11:A20 are empty and A21:A30 are 2, the

> > above
> >> formula in B21 would give AVERAGE(A12:A21), or 2.
> >>
> >> What I want is the average of the previous 10 meaningful cells so - in

> > this
> >> case - the average of A2:A10 and A21, or (9*1+2)/10 = 1.1
> >>
> >> Question : Is there a possibility to calculate the average of the
> >> previous
> >> 10 meaningful cells (0 is meaningful, blank is not)
> >>
> >> Thanks in advance.
> >> Gilbert
> >>
> >>
> >>

> >
> >

>
>



 
Reply With Quote
 
Gilbert De Ceulaer
Guest
Posts: n/a
 
      26th Feb 2006
Did exactly what I wanted. Thank you, Bernard

"Bernard Liengme" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Gilbert,
> I found it difficult to think 'backwards' with Excel function so I did it
> in VBA
> With =myavg(A21) this gives 1.1 for your data
>
> Function myAvg(mystart)
> Application.Volatile
>
> Set mycell = mystart
> mysum = 0#
> mycount = 0#
> Do While mycount < 10
> If Application.WorksheetFunction.IsNumber(mycell.Value) Then
> mysum = mysum + mycell.Value
> mycount = mycount + 1
> End If
> Set mycell = mycell.Offset(-1, 0)
> Loop
> myAvg = mysum / 10#
>
> End Function
>
> best wishes
> --
> Bernard V Liengme
> www.stfx.ca/people/bliengme
> remove caps from email
>
> "Gilbert De Ceulaer" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> B10 = AVERAGE(A1:A10),
>> B11 = AVERAGE(A2:A11), etc.
>>
>> In case there are empty cells in the A-column, the result is not correct
>> anymore because AVERAGE does not take en empty cell into account.
>> For instance if A1:A10 are 1, A11:A20 are empty and A21:A30 are 2, the
>> above formula in B21 would give AVERAGE(A12:A21), or 2.
>>
>> What I want is the average of the previous 10 meaningful cells so - in
>> this case - the average of A2:A10 and A21, or (9*1+2)/10 = 1.1
>>
>> Question : Is there a possibility to calculate the average of the
>> previous 10 meaningful cells (0 is meaningful, blank is not)
>>
>> Thanks in advance.
>> Gilbert
>>
>>
>>

>
>



 
Reply With Quote
 
Bernard Liengme
Guest
Posts: n/a
 
      26th Feb 2006
Impressive!
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"Bob Phillips" <(E-Mail Removed)> wrote in message
news:u2gk%(E-Mail Removed)...
> You're right, shouldn't have relied on the OP's data.
>
> Maybe this is better
>
> =SUM(SUBTOTAL(9,OFFSET($A$1,LARGE(IF($A$1:$A10<>"",ROW($A$1:$A10)),ROW(INDIR
> ECT("1:10")))-1,0)))/MIN(COUNT($A$1:$A10),10)
>
> which is an array formula, it should be committed with Ctrl-Shift-Enter,
> not
> just Enter.
>
> --
>
> HTH
>
> Bob Phillips
>
> (remove nothere from the email address if mailing direct)
>
> "Bernard Liengme" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Not sure this works.
>> If data in A is 99, 99,99 99, 1,1,1,1,1,1, <10 blanks>,
>> 2,2,2,2,2,2,2,2,2,2,2,
>> Value from formula after B20 are not correct because of the LARGE

> function.
>> --
>> Bernard V Liengme
>> www.stfx.ca/people/bliengme
>> remove caps from email
>>
>> "Bob Phillips" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>> > Try this in B10
>> >
>> > =AVERAGE(LARGE(IF(A$1:A10<>"",A$1:A10),ROW(INDIRECT("1:10"))))
>> >
>> > which is an array formula, it should be committed with
>> > Ctrl-Shift-Enter,
>> > not
>> > just Enter. Copy down.
>> >
>> > --
>> >
>> > HTH
>> >
>> > Bob Phillips
>> >
>> > (remove nothere from the email address if mailing direct)
>> >
>> > "Gilbert De Ceulaer" <(E-Mail Removed)> wrote in message
>> > news:#(E-Mail Removed)...
>> >> B10 = AVERAGE(A1:A10),
>> >> B11 = AVERAGE(A2:A11), etc.
>> >>
>> >> In case there are empty cells in the A-column, the result is not

> correct
>> >> anymore because AVERAGE does not take en empty cell into account.
>> >> For instance if A1:A10 are 1, A11:A20 are empty and A21:A30 are 2, the
>> > above
>> >> formula in B21 would give AVERAGE(A12:A21), or 2.
>> >>
>> >> What I want is the average of the previous 10 meaningful cells so - in
>> > this
>> >> case - the average of A2:A10 and A21, or (9*1+2)/10 = 1.1
>> >>
>> >> Question : Is there a possibility to calculate the average of the
>> >> previous
>> >> 10 meaningful cells (0 is meaningful, blank is not)
>> >>
>> >> Thanks in advance.
>> >> Gilbert
>> >>
>> >>
>> >>
>> >
>> >

>>
>>

>
>



 
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
7 previous days average =?Utf-8?B?Q2FybGVl?= Microsoft Excel Worksheet Functions 9 28th Oct 2007 09:02 PM
TO Average Previous values =?Utf-8?B?U3BlZWR5?= Microsoft Excel Worksheet Functions 7 20th Oct 2007 07:08 AM
Average of previous values =?Utf-8?B?U3BlZWR5?= Microsoft Excel Misc 4 14th Oct 2007 07:28 AM
Average based on the previous row Gary Microsoft Excel Worksheet Functions 5 6th Feb 2007 02:47 PM
average cells, show 0 if nothing to average =?Utf-8?B?S3ljYWp1bg==?= Microsoft Excel Misc 8 21st Jun 2006 07:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:23 AM.