Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default formula - average using a count

Hi All

Im having trouble making a formula that averages a sum by the number of cells that contain data
I.e
I have 12 cells, on a row. (A1 to A12). In A13 i have a total of A1 to A12
In A13 i need to average the total by the number of cells in A1-A12 that contain data
i know i can have a cell that does the count, and then another cell that divides the total by the cell count, but that make this messy on the spreadsheet. (Used for financial reporting.

Im not sure on an appropriate formula.
Could someone possibly tell me a formula/function that i can use for the above

Thanks heaps

Toby.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default formula - average using a count

Toby

one way:

=SUM(A1:A12)/COUNTIF(A1:A12,"<")

Regards

Trevor


"Toby T" wrote in message
...
Hi All.

Im having trouble making a formula that averages a sum by the number of

cells that contain data.
I.e.
I have 12 cells, on a row. (A1 to A12). In A13 i have a total of A1 to

A12.
In A13 i need to average the total by the number of cells in A1-A12 that

contain data.
i know i can have a cell that does the count, and then another cell that

divides the total by the cell count, but that make this messy on the
spreadsheet. (Used for financial reporting.)

Im not sure on an appropriate formula.
Could someone possibly tell me a formula/function that i can use for the

above.

Thanks heaps.

Toby.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default formula - average using a count

Trevors suggestion is probably the best one but if you want a function this
does it.....

Public Function NZAvg(NZR As Range)
Dim nzcount As Long, nzsum As Double, cell As Variant
nzcount = 0
For Each cell In NZR
If Val(cell.Value) 0 Then
nzcount = nzcount + 1
nzsum = nzsum + cell.Value
End If
Next
If nzcount 0 Then
NZAvg = nzsum / nzcount
Else
NZAvg = CVErr(xlErrValue)
End If
End Function


put the formula =NZAvg(A1:A12) in the worksheet cell to calculate the
non-zero average for the range.

Cheers
Nigel

"Toby T" wrote in message
...
Hi All.

Im having trouble making a formula that averages a sum by the number of

cells that contain data.
I.e.
I have 12 cells, on a row. (A1 to A12). In A13 i have a total of A1 to

A12.
In A13 i need to average the total by the number of cells in A1-A12 that

contain data.
i know i can have a cell that does the count, and then another cell that

divides the total by the cell count, but that make this messy on the
spreadsheet. (Used for financial reporting.)

Im not sure on an appropriate formula.
Could someone possibly tell me a formula/function that i can use for the

above.

Thanks heaps.

Toby.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default formula - average using a count

Thanks heaps Trevor
That works great.
Reply
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
A formula to AVERAGE IF but only average a set number of values [email protected] Excel Worksheet Functions 2 January 31st 08 08:28 PM
need to count/average if... Need Help 123 Excel Worksheet Functions 6 December 15th 05 11:31 PM
how to average and use sum min and count within one cell gwtechie72 Excel Worksheet Functions 4 October 19th 05 03:34 AM
how does one convert text to a formula "average(A:A)" to =average( phshirk Excel Worksheet Functions 4 April 14th 05 01:20 AM
Count and then average Al Excel Worksheet Functions 4 November 17th 04 03:38 AM


All times are GMT +1. The time now is 04:03 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"