Date: prev next · Thread: first prev next last
2021 Archives by date, by thread · List index


At 21:46 24/03/2021 -0600, Joe Conner wrote:
I am confused about how to count a number of cells that have a number. In Calc, if cells a1:a11 each may or may not have a number in it, what formula may I use to count how many cells have a number? I do not want the sum of the numbers, just how many cells contain a number.

This all depends on what you mean by "a number"! Do you just mean that the cell has something in it, so presumably a number - just anything, i.e. that the cell is not empty? If you mean specifically a number, do you include an explicit zero? And how about a cell that has a blank or blanks, which would be interpreted the same way as zero in many calculation contexts? Note that a cell containing blanks is different from an empty cell; you may or may not wish to include such cells. You probably won't want to include text strings such as "three", even though that is a number in one sense; but how about a cell containing a number expressed as digits but in the form of a text string, e.g. the character "3" as distinct from the numerical value 3? (This may arise from entering a number into a cell formatted as Text or by entering a leading apostrophe - or by pasting material from elsewhere.)

The COUNT() function ignores empty cells and those that contain text, so may well be all you need.

Otherwise you may like to consider formulae involving COUNTA() or COUNTIF(). Note also that it is sometimes easier to calculate the inverse of something, so you could consider using COUNTBLANK() (which should really be called COUNTEMPTY(), since it fails to include cells containing explicit blank spaces), and subtracting the result from the number of cells in the range.

Exactly what you choose to do depends on how resilient you want your spreadsheet to be to rogue or erroneous cell contents as a result of later errors on your part (we all make them) or on the part of others who may use the spreadsheet.

I trust this helps.

Brian Barker


--
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.