PC Review


Reply
Thread Tools Rate Thread

Calculating average of percentages

 
 
Jimmy O
Guest
Posts: n/a
 
      23rd Jun 2008
I have a column of percentage values some of which are zeros. I wish to
calculate an average of the percentage values but also wish to exclude all
zero values from the average formula but I'm not sure how to write an
argument to do this. Any help is appreciated.
 
Reply With Quote
 
 
 
 
Mike
Guest
Posts: n/a
 
      23rd Jun 2008
'Loops thru A1 to A10
Sub test()
Dim sumOfAverages As Variant
Dim iCounter As Integer
sumOfAverages = 0
For i = 1 To 10
If Cells(i, 1).Value > 0 Then
sumOfAverages = sumOfAverages + Cells(i, 1).Value
iCounter = iCounter + 1
End If
Next
If iCounter > 0 Then
sumOfAverages = Format(sumOfAverages / iCounter, "0%")
Range("C1").Value = sumOfAverages
End If
End Sub

"Jimmy O" wrote:

> I have a column of percentage values some of which are zeros. I wish to
> calculate an average of the percentage values but also wish to exclude all
> zero values from the average formula but I'm not sure how to write an
> argument to do this. Any help is appreciated.

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      23rd Jun 2008
=AVERAGE(IF(rng<>0,rng))

which is an array formula, it should be committed with Ctrl-Shift-Enter, not
just Enter.
Excel will automatically enclose the formula in braces (curly brackets), do
not try to do this manually.
When editing the formula, it must again be array-entered.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Jimmy O" <Jimmy (E-Mail Removed)> wrote in message
news:496F2DA0-5CC6-4522-A453-(E-Mail Removed)...
>I have a column of percentage values some of which are zeros. I wish to
> calculate an average of the percentage values but also wish to exclude all
> zero values from the average formula but I'm not sure how to write an
> argument to do this. Any help is appreciated.



 
Reply With Quote
 
Dallman Ross
Guest
Posts: n/a
 
      23rd Jun 2008
Hey, Bob -- that's very nice. I did not know AVERAGE could work
with an IF included inside! Neat-o. I've been doing this sort
of thing for years manually by adding up non-zero numbers in the range
and dividing by a COUNTIF of non-zero numbers in the range.

Handy!

=dman=

===================
In <(E-Mail Removed)>, Bob Phillips
<(E-Mail Removed)> spake thusly:

> =AVERAGE(IF(rng<>0,rng))
>
> which is an array formula, it should be committed with Ctrl-Shift-Enter, not
> just Enter.
> Excel will automatically enclose the formula in braces (curly brackets), do
> not try to do this manually.
> When editing the formula, it must again be array-entered.
>

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      24th Jun 2008
Others work just as well, MAX, MIN, MEDIAN, etc.

In 2007 they have added a few, I think AVERAGEIF is one, but not all. Go
figure!

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Dallman Ross" <dman@localhost.> wrote in message
news:g3p8qe$i8v$(E-Mail Removed)...
> Hey, Bob -- that's very nice. I did not know AVERAGE could work
> with an IF included inside! Neat-o. I've been doing this sort
> of thing for years manually by adding up non-zero numbers in the range
> and dividing by a COUNTIF of non-zero numbers in the range.
>
> Handy!
>
> =dman=
>
> ===================
> In <(E-Mail Removed)>, Bob Phillips
> <(E-Mail Removed)> spake thusly:
>
>> =AVERAGE(IF(rng<>0,rng))
>>
>> which is an array formula, it should be committed with Ctrl-Shift-Enter,
>> not
>> just Enter.
>> Excel will automatically enclose the formula in braces (curly brackets),
>> do
>> not try to do this manually.
>> When editing the formula, it must again be array-entered.
>>



 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      24th Jun 2008
Also, even without the embedded if you could have done it without all that
hard work

=SUM(A1:A100)/COUNTIF(A1:A100,"<>0")

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Dallman Ross" <dman@localhost.> wrote in message
news:g3p8qe$i8v$(E-Mail Removed)...
> Hey, Bob -- that's very nice. I did not know AVERAGE could work
> with an IF included inside! Neat-o. I've been doing this sort
> of thing for years manually by adding up non-zero numbers in the range
> and dividing by a COUNTIF of non-zero numbers in the range.
>
> Handy!
>
> =dman=
>
> ===================
> In <(E-Mail Removed)>, Bob Phillips
> <(E-Mail Removed)> spake thusly:
>
>> =AVERAGE(IF(rng<>0,rng))
>>
>> which is an array formula, it should be committed with Ctrl-Shift-Enter,
>> not
>> just Enter.
>> Excel will automatically enclose the formula in braces (curly brackets),
>> do
>> not try to do this manually.
>> When editing the formula, it must again be array-entered.
>>



 
Reply With Quote
 
Jimmy O
Guest
Posts: n/a
 
      24th Jun 2008
Many thanks Bob. This works nicely. jo

"Bob Phillips" wrote:

> Also, even without the embedded if you could have done it without all that
> hard work
>
> =SUM(A1:A100)/COUNTIF(A1:A100,"<>0")
>
> --
> HTH
>
> Bob
>
> (there's no email, no snail mail, but somewhere should be gmail in my addy)
>
> "Dallman Ross" <dman@localhost.> wrote in message
> news:g3p8qe$i8v$(E-Mail Removed)...
> > Hey, Bob -- that's very nice. I did not know AVERAGE could work
> > with an IF included inside! Neat-o. I've been doing this sort
> > of thing for years manually by adding up non-zero numbers in the range
> > and dividing by a COUNTIF of non-zero numbers in the range.
> >
> > Handy!
> >
> > =dman=
> >
> > ===================
> > In <(E-Mail Removed)>, Bob Phillips
> > <(E-Mail Removed)> spake thusly:
> >
> >> =AVERAGE(IF(rng<>0,rng))
> >>
> >> which is an array formula, it should be committed with Ctrl-Shift-Enter,
> >> not
> >> just Enter.
> >> Excel will automatically enclose the formula in braces (curly brackets),
> >> do
> >> not try to do this manually.
> >> When editing the formula, it must again be array-entered.
> >>

>
>
>

 
Reply With Quote
 
Dallman Ross
Guest
Posts: n/a
 
      24th Jun 2008
In <(E-Mail Removed)>, Bob Phillips
<(E-Mail Removed)> spake thusly:

> Also, even without the embedded if you could have done it without all that
> hard work
>
> =SUM(A1:A100)/COUNTIF(A1:A100,"<>0")


True. Thanks for the reminder. Looking at my sheets, I see
that's what I've been doing. :-) I'll try the AVERAGE(IF...)
thing sometime soon enough, though. Thanks again.

=dman=
>

 
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
Get the Average percentages? Also, #DIV/0! error Roady Microsoft Excel Misc 1 26th Sep 2008 08:22 PM
Average Percentages Excluding Zero Percentages MPHernandez Microsoft Excel Programming 0 19th Mar 2008 06:54 PM
Calculating percentages =?Utf-8?B?WWFyaQ==?= Microsoft Excel Worksheet Functions 2 30th Nov 2005 07:38 PM
Calculating percentages Carol Microsoft Excel Misc 2 31st Aug 2004 03:38 AM
average of percentages between 1% and 100% in a column SteveMac Microsoft Excel Misc 1 2nd Apr 2004 06:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:46 PM.