View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bernard Liengme Bernard Liengme is offline
external usenet poster
 
Posts: 4,393
Default How to do COUNTIF when cells are not in a consequtive column?

This will average non-zero cells: =SUM(D3,G3,J3)/SUM((D30)+(G30)+(J30))
Note that negative values will give an incorrect answer
This will average only positive values and ignore negative and zero values
=SUM(D3*(D30),G3*(G30),J3*(J30))/SUM((D30)+(G30)+(J30))
Convert commas (,) to semicolons (;) for you local version of Excel
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Karin" wrote in message
...
I would like to average an array of cells, but only include those cells
whose
cell value is greater than zero.
I have an array like (D3;G3;J3), and want to include only those
AVERAGE(D3;G3;J3). I have tried to use
SUM(D3;G3;J3)/COUNTIF((D3;G3;J3);"0" )
but the COUNTIF doesn't allow that arrayform (D3;G3;J3). If I for example
put COUNTIF((D3:D7);"0") , that works - but that's not the cells where my
data is!
How should I write the array so that it works?
Yours
Karin