Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 1
Default Conditional Formatting discarding zeros

I haven't found this example in the threads, I hope someone can help me. I need to make the following formula disregard blanks and zeros. Please help.

=IF(COUNT(B10:B62),AVERAGE(B10:B62))

Thanks, Jwest
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 829
Default Conditional Formatting discarding zeros

"Jwest616" wrote:
I need to make the following formula disregard blanks
and zeros. Please help.
=IF(COUNT(B10:B62),AVERAGE(B10:B62))


You fix this with changes to the formula, not with a Conditional Format.

AVERAGE already ignores empty cells and cells with text, which includes
cells that appear blank, but they actually contain the null string.

To ignore zeros, it depends on what version of the Excel you are using or
targeting.

If you use Excel 2007 or later and you do not require Excel 2003
compatibility, use the following formula:

=IFERROR(AVERAGEIF(B10:B62,"<0"),"")

If you need Excel 2003 compatibility, use the following array-entered
formula (press ctrl+shift+Enter instead of just Enter):

=IF(COUNTIF(B10:B62,"<0")0,AVERAGE(IF(B10:B62<0 ,B10:B62)),"")

The change from COUNT to COUNTIF avoids a #DIV/0 error when no cells
qualify.

Alternatively, you can use the following normally-entered formula (just
press Enter as usual):

=IF(COUNTIF(B10:B62,"<0"),
SUMPRODUCT(--(B10:B62<0),B10:B62)/COUNTIF(B10:B62,"<0"),"")

Change "" (null string) to zero if you prefer. But in that case, you can
simplify the last formula as follows:

=SUMPRODUCT(--(B10:B62<0),B10:B62)/MAX(1,COUNTIF(B10:B62,"<0"))

In the SUMPRODUCT expression, the double negative converts TRUE and FALSE to
1 and 0, as SUMPRODUCT requires for your purposes.

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
Formatting zeros as dashes Arun Excel Discussion (Misc queries) 1 December 17th 09 05:10 PM
Adding Leading Zeros; Formatting as Time AltaEgo Excel Programming 0 May 4th 09 02:26 AM
Conditional formatting to ignore zeros Jock Excel Worksheet Functions 5 October 17th 07 09:35 AM
Discarding all hidden cells? jsb88 Excel Programming 2 October 9th 06 12:37 PM
Formatting Zeros OriginalStealth Excel Programming 2 August 13th 04 03:28 PM


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