View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Countif to exclude blanks

I suggest using the SUMIF() function and a helper column, plus naming
the ranges as follows...

Column labeled "Week" (Col "C"):
Select all cells under label;
In the namebox type the sheetname wrapped in apostrophes,
then the exclamation character,
then "Week" as the range name (without quotes);
Example: 'sheet name'!Week
Press the 'Enter' key

Blank column to the right of "Week" (Col "E"):
Select the same number of cells as the range named "Week";
In the namebox type the sheetname wrapped in apostrophes,
then the exclamation character,
then "Count" as the range name (without quotes);
Example: 'sheet name'!Count
Press the 'Enter' key

While selected, start typing the following formula...
=IF(LEN($A1),1,0)
..and while holding down the 'Ctrl' key press 'Enter'

In the cells to the right of your list (Week1,Week2,Week3,Week4),
enter the following formulas...

=SUMIF(Week,"Week1",Count)
=SUMIF(Week,"Week2",Count)
=SUMIF(Week,"Week3",Count)
=SUMIF(Week,"Week4",Count)

Here's the results I get...

Week1 2
Week2 2
Week3 4
Week4 2

Note that you can hide the helper column if desired!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion