Hello,
I have a range of cells (B6:M6) and I want to count how many have data. My problem is that all of the cells reference cells on another worksheet. Every cell starts out like =Bethlehem!B6. I want to ignore cells that have a reference in it when I count. I know how to do it if you want to ignore these cells as follows: =countif(b6:m6,"<> 0"). Those cell references return a 0 if they have no data in them. However, a user might actually enter a 0 in the referenced cell and I need to count that one. The above formula would exclude it. Any suggestions?
Thank you very much,
Dave
Last edited by coachdave; 08-21-2009 at 11:19 AM. Reason: Solved
Hi Dave,
Can you adjust your formulas to something like:
=IF(Bethlehem!B6="","",Bethlehem!B6)
if so, you could then just use
=COUNT(B6:M6)
to get the number of cells with values in them.
Paul,
Thanks for the suggestion. However, the referenced cells never seem to have a value of "". The value is either an actual number entered by the user or the reference and the reference's value seems to be 0 not "".
Dave, I think Paul was suggesting you alter your initial formulae in B6:M6 such that should the target cell be blank a Null is returned to the cell rather than 0, so
B6: =IF(Bethlehem!B6="","",Bethlehem!B6)
copied to M6
The above simply checks to see if the cell B6 on Bethlehem sheet is blank or not, if it is blank it returns a Null value else it returns the content of B6 (this will include valid 0 entry)
Once the above is input you can then as advised by Paul use the COUNT function if we're assuming B6:M6 on Bethlehem sheet contain numerics
=COUNT(B6:M6)
The Nulls you returned for the otherwise blank cells will be ignored in the above as a Null is in essence a 0 length text string and thus not numeric, COUNT only looks at numeric values.
If you're returning a mixture of text and numbers then another alternative would be:
=COUNTA(B6:M6)-COUNTBLANK(B6:M6)
This works because COUNTBLANK treats Null as Blank (COUNTA does not).
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Thanks to both of you.
Paul when I replied to you I did change the formulas but it wasn't working. I must have had a typo in there because I changed them all again and I am getting the count that I want.
Agai, thanks to both of you for your help.![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks