+ Reply to Thread
Results 1 to 13 of 13

Count including Blank Cells

  1. #1
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481

    Count including Blank Cells

    I am trying to use a formula to count the number of rows in a worksheet including blank cells.

    If I use
    =COUNTA(A:A)
    then it returns the count of cells which contain a value

    If I use
    =COUNTIF(A:A,"")
    it will count the blank cells in column A within the current used range in Excel 2000

    using the same COUNTIF formula returns a count of the blank cells in the entire column in Excel 2007.

    Therefore in Excel 2000 I can use
    =COUNTA(A:A) + COUNTIF(A:A,"") and get the correct count

    In Excel 2007 the same formula returns a count of all the cells.

    Any idea of a fomula which will work in Excel 2007 that will return the empty cells in the used range?
    Even better would be a formula which will return the same count (used and empty cells) in both 2000 and 2007.

    TIA

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482
    This code is counts the number of rows from A1 to the last used cell
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    08-10-2006
    Posts
    723
    hi,

    one solution maybe

    =COUNTBLANK(A1:A16)+COUNTA(A2:A16)
    change range to suit
    steve

  4. #4
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481
    Thanks for the code Dave but I need to do this in a worksheet function rather than with code. Any suggestions?

    Thanks for the suggestion Steve. However I need the function to work on the entire column and therefore do not know the range.
    If I use
    =COUNTBLANK(A:A)+COUNTA(A:A)
    then it simply returns the count of the entire row.

    Does anyone know a way to count the cells including blank cells with a worksheet function?

    i.e.
    Col A could contian numbers and text and blank spaces <blank>
    Heading 1
    Heading 2
    <blank>
    test 1
    <blank>
    result
    3
    4
    5
    <blank>
    test 2
    <blank>
    result
    6
    7
    8

    =COUNTA(A:A)
    returns 12 in either Excel 2000 or Excel 2007

    =COUNTIF(A:A,"")
    returns 4 in Excel 2000 but returns 65524 in Excel 2007 (in compatability mode)

    I need a function that will return 16 for the example column A shown in both Excel 2000 and Excel 2007

    In Excel 2000 I can use

    =COUNTA(A:A)+COUNTIF(A:A,"")
    But in Excel 2007 this same function gives 65536 (in compatability mode).

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    I don't have 2007, but I think these should work:

    If you always start at row 1:

    Please Login or Register  to view this content.
    if not:

    Please Login or Register  to view this content.
    This last formula must, however, be confirmed with CTRL+SHIFT+ENTER not just ENTER. You will see { } brackets appear around the fomrula
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  6. #6
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481
    Thanks NBVC

    The first formula worked perfectly in Excel 2000 and 2007
    (I haven't tried it in 2003 yet).

    The second formula worked in Excel 2007
    (once I remembered it was an array formula and used Ctrl+Shift+Enter to confirm it).
    However the second formula returned a #NUM error in Excel 2000.

    But since the first formula is working for my purposes I'll go with that.

    Thanks agian!

  7. #7
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Quote Originally Posted by bhofsetz
    Thanks NBVC

    The second formula worked in Excel 2007
    (once I remembered it was an array formula and used Ctrl+Shift+Enter to confirm it).
    However the second formula returned a #NUM error in Excel 2000.
    Before XL2007, you can't use whole column references such as A:A with Array formulas...but it is okay in 2007.

    so to make the second formula work in 2000 and 2003,

    Please Login or Register  to view this content.
    which references entire column except last row.

  8. #8
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481
    Excelent!

    Thanks for the explination and correction to the formula for 2000 and 2003

  9. #9
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481
    One more issue I just came across.

    If column A does not contain numbers in any of the cells then the formula does not work.
    I know my example had numbers but there is a possibility that in use that column may contain only text.

    Thanks

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Try:

    Please Login or Register  to view this content.
    confirmed with CTRL+SHIFT+ENTER

  11. #11
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481
    Thanks for the clarification. I was able to use the formulas and information you provided.

    Thanks again

  12. #12
    Registered User
    Join Date
    02-17-2015
    Location
    India
    MS-Off Ver
    2007
    Posts
    1

    Re: Count including Blank Cells

    Hi NBVC,

    I tried both the formulas in my Macro in Excel 2007 but i am getting an error as mentioned below:

    Expected List Separator or ).

    Can you please guide me with it as i am newbie to excel automation.

  13. #13
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Count including Blank Cells

    Hi, morenitsvineet,

    welcome to ExcelForum. Did you realize that the thread you entered is nearly 7 years old?

    According to Forum Rule 2 you should start your own thread and post the code youi triued.

    Maybe itīs just that you did not use FormulaArray tro create the correct formula but hard to tell with as little informationm as provided.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1