+ Reply to Thread
Results 1 to 14 of 14

Countif for cells starting with a number combined with text - not working

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-07-2005
    Location
    England
    MS-Off Ver
    Office 2019 Enterprise
    Posts
    473

    Countif for cells starting with a number combined with text - not working

    Hi, I'm having a bit of a battle trying to get this formula to work. I want to find out how many cells start with number 9

    Consider the following cells in A1:A4

    987-123
    987-456
    815-952
    751-542

    I'm trying COUNTIF(A:A,"9*") but it produces a result of 0.

    This seems to just be a number problem. If I was to pretend I was looking for anything beginning with A then it works but just doesn't like numbers?

    Hope someone can help. John

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Countif for cells starting with - not working

    I just used this and it returned 2

    =COUNTIF(A:A,"9*")

    Maybe attach your offending sample workbook.
    HTH
    Regards, Jeff

  3. #3
    Valued Forum Contributor PaulSP8's Avatar
    Join Date
    11-21-2017
    Location
    Chorley, England
    MS-Off Ver
    2013 & 2021
    Posts
    437

    Re: Countif for cells starting with - not working

    Weird, that is how it should work and how it works on mine when I test it.

    When I check the cell it's saying that it's not a number (=ISNUMBER() ) so that shouldn't be the problem.

    Have you checked the formatting of the cell to see what it's been seen as?

    Have you checked that Automatic Calculation is switched on?

  4. #4
    Forum Contributor
    Join Date
    07-07-2005
    Location
    England
    MS-Off Ver
    Office 2019 Enterprise
    Posts
    473

    Re: Countif for cells starting with a number combined with text - not working

    Hi, thanks for the reply. I have attached my sheet to help further! Sorry I meant to say I am using Excel 2003 - not sure if that matters
    Attached Files Attached Files

  5. #5
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Countif for cells starting with a number combined with text - not working

    You might need to use this, and with Sumproduct, you shouldn't use full references.

    =SUMPRODUCT(--(LEFT(A1:A11)="1"))

  6. #6
    Valued Forum Contributor PaulSP8's Avatar
    Join Date
    11-21-2017
    Location
    Chorley, England
    MS-Off Ver
    2013 & 2021
    Posts
    437

    Re: Countif for cells starting with a number combined with text - not working

    The cells you are trying to count in that workbook are numbers, not text - The examples you gave in the first post will be seen as text by Excel.

    This will work for counting numbers;

    Formula: copy to clipboard
    =SUMPRODUCT(--(LEFT(A:A,1)="9"))

  7. #7
    Forum Contributor
    Join Date
    07-07-2005
    Location
    England
    MS-Off Ver
    Office 2019 Enterprise
    Posts
    473

    Re: Countif for cells starting with a number combined with text - not working

    Perfect, thank you both very much that has worked.

    I did want to take it one step further and have it look at a certain cell for the "9" but that doesn't seem to work. This is a nice-to-have but if it's obvious to you then I would like it. I tried =SUMPRODUCT(--(LEFT(A:A,1)=C1)) - where C1 contains the number 9 - but it doesn't like it?

  8. #8
    Valued Forum Contributor PaulSP8's Avatar
    Join Date
    11-21-2017
    Location
    Chorley, England
    MS-Off Ver
    2013 & 2021
    Posts
    437

    Re: Countif for cells starting with a number combined with text - not working

    Quote Originally Posted by johncassell View Post
    where C1 contains the number 9 - but it doesn't like it?
    You can use;

    Formula: copy to clipboard
    =SUMPRODUCT(--(LEFT(A:A,1)=TEXT(C1,"0")))


    jeffreybrown was right, you should amend the formula to include number the row ranges as well.

  9. #9
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,222

    Re: Countif for cells starting with a number combined with text - not working

    Please try
    =SUMPRODUCT(--(--LEFT(A:A,1)=C1))

    LEFT(A:A,1) is text while C1 is number

  10. #10
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Countif for cells starting with a number combined with text - not working

    Hi Bo,

    That still returns #VALUE!

  11. #11
    Forum Contributor
    Join Date
    07-07-2005
    Location
    England
    MS-Off Ver
    Office 2019 Enterprise
    Posts
    473

    Re: Countif for cells starting with a number combined with text - not working

    Magic - thanks thats working.

    =SUMPRODUCT(--(LEFT(A:A,1)=TEXT(C1,"0")))
    "you should amend the formula to include number the row ranges as well" - do you mean put A1:A2000 instead of A:A ?

  12. #12
    Valued Forum Contributor PaulSP8's Avatar
    Join Date
    11-21-2017
    Location
    Chorley, England
    MS-Off Ver
    2013 & 2021
    Posts
    437
    Quote Originally Posted by johncassell View Post
    do you mean put A1:A2000 instead of A:A ?
    Yeah, it's always better if it's a known range :-)

  13. #13
    Forum Contributor
    Join Date
    07-07-2005
    Location
    England
    MS-Off Ver
    Office 2019 Enterprise
    Posts
    473

    Re: Countif for cells starting with a number combined with text - not working

    Yes I actually do that, thanks. Back in the early days I would put A:A for everything then wonder why the calculations were taking so long!

  14. #14
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Countif for cells starting with a number combined with text - not working

    The problem with full references (A:A) with Sumproduct, Sumproduct will reference all 1,000,000+ rows even if they are not part of your intended range.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Countif to include any number or specific text in merged cells
    By Brewdawg in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-26-2015, 06:29 PM
  2. [SOLVED] Countif function stops working after a certain number of cells
    By jameseps in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-17-2012, 08:05 PM
  3. Replies: 4
    Last Post: 11-30-2010, 05:14 PM
  4. can the text of two cells be combined with merge
    By jamie.c in forum Excel General
    Replies: 9
    Last Post: 01-20-2010, 10:23 AM
  5. Extracting numbers from a combined text & number string
    By astrikor in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-25-2007, 08:45 AM
  6. [SOLVED] text and number combined in a cell
    By TimN in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-11-2006, 06:05 PM
  7. Replies: 1
    Last Post: 04-08-2005, 12:06 AM

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