Search code examples
excelcountoffice-2010

Counting how many cells, values, and formulas are in a sheet with Excel


Microsoft Word 2010 offers an option to see how many words there are in a document. Is there a similar option in Excel 2010 to see how many cells/values/formulas I have in a specific workbook or a specific sheet?

In Word 2010, the word count can be found in File > Informations > Show all properties. In Excel though, there isn't nearly as much information. Is it hidden somewhere else?


Solution

  • You might use the SpecialCells property of the Range object to find this information. For example, ActiveSheet.Cells.SpecialCells(xlCellTypeFormulas).Count will return the number of cells containing formulas on the active sheet, and ActiveSheet.Cells.SpecialCells(xlCellTypeConstants).Count will return the number of cells containing constants. See the documentation for more information.

    If you wanted totals for an entire workbook, you could loop through the elements of the Workbook object's Worksheets collection, use the SpecialCells property of each Worksheet object's Cells member to get the numbers you want, and add up the totals.