+ Reply to Thread
Results 1 to 13 of 13

Looking for a formula to count single digits vs. double digits?

  1. #1
    Registered User
    Join Date
    01-05-2014
    Location
    Minnesota, United States
    MS-Off Ver
    Excel 2011
    Posts
    4

    Looking for a formula to count single digits vs. double digits?

    Hello All,


    Happy New Year!!!


    First time in a cite like this. I have been reading some of the posts and love all the help folks are willing to give.



    I am looking to add digits that appear in a column and don't seem to understand how to do the array properly.

    Let's say I have column L and have information in L10 - L287. I have the following numbers in the columns,

    L105 2, 3, 7, 12, 17
    L106 3, 5, 8, 11, 12
    L107 4, 5, 6, 14, 17

    Say that I simply want to count how many times each number appears. In putting in formula's and trying to find out how may times JUST 7 appears, NOT 17, it does not work. It counts the 7 as well as the 17 and gives me a value of 3 times. I would like to be able to have it tell me there is one 7 and two 17's.

    The formula I have used is this: =SUM(LEN(L105:L287)-LEN(SUBSTITUTE(L105:L287,"7","")))/LEN("7")

    If I do the same formula and use 17, it will pick out just the 17's.

    The formula works for double digits but not for single digits?

    Clearly I don't understand how this is done. Sorry. I am not the brightest bulb on the tree.

    Anyone know how I can do that?

    Thank you in advance for any assistance. Have a great evening.

    I love groups like this. Makes you realize people are good.

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Looking for a formula to count single digits vs. double digits?

    With
    A1: the number to get the count of...12

    This regular formula returns the count of occurrences of that number in the referenced range (even if it appears multiple times in one cell)
    Please Login or Register  to view this content.
    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Looking for a formula to count single digits vs. double digits?

    If you always have a comma after and a space before the 7, the string you want to search for is actually: " 7,"

    How does this do? =COUNTIF(L105:L287, "* 7,*")


    EDIT: That only works to count the number of times the number is in the string but not at the end. This array version seems to count each cell once correctly:

    =SUM(--(ISNUMBER(SEARCH(" 7,",L105:L287&","))))

    ...confirmed by pressing CTRL-SHIFT-ENTER to activate the array.
    Last edited by JBeaucaire; 01-05-2014 at 08:14 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    01-05-2014
    Location
    Minnesota, United States
    MS-Off Ver
    Excel 2011
    Posts
    4

    Re: Looking for a formula to count single digits vs. double digits?

    Thank you so much for your reply Ron. I copied your exact formula in my computer and it read a number of 331 ??? That is about 321 too many.

    I should clarify that I am keeping stats for a hockey team for some neighborhood kids. Each time they are on the ice, they receive a + when we score and receive a - if we get scored on. To keep track of who was on the ice I simply use the 1, 2, 3, 4, 5 in that column. Each players number that was on the ice is represented and there are normally 5 players on the ice. Sometimes less, but the principle is the same that I use the numbers and separate them by a ,

    the number of the players on the team are 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 17 . Those are all of the numbers for the kids on the team.

    The formula I used works for 8, 10, 11, 12, 13, 14, 15 and 17. It won't work for the others as the numbers show up in the ones spot for the other players numbers.


    You have (" "&A1, 2), " Am I supposed to replace the A1 and use 1? Do I put in &A1, 2, 3, 4, 5, 6, 7, 8, 9, so it works for all single numbers?

    I am sorry to be a pain in your a$$ and I truly appreciate your even being willing to respond to this. Thank you so much.

    I will keep my eye on this for a while in the hopes that you (or anyone else) will reply.

    Again, thanks a million Ron. I will keep my eye out.

  5. #5
    Registered User
    Join Date
    01-05-2014
    Location
    Minnesota, United States
    MS-Off Ver
    Excel 2011
    Posts
    4

    Re: Looking for a formula to count single digits vs. double digits?

    JB that one worked great but does NOT count the #7 in a case where it reads 7, 11, 12, 14, 15. Is that because it won't read when 7 is the first numbers? That is what it appears. I counted all fo them and also did the formula with the #6. Same thing happened. Always worked unless the number was the first number.

  6. #6
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Looking for a formula to count single digits vs. double digits?

    Since no two players will have the same number, there's no point making Excel work so hard.
    Try variations of JBeaucaire's suggestion.

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Looking for a formula to count single digits vs. double digits?

    If you put a comma manually at the end of each of the strings, then the simple formula given first should always work, else the array formula given second should do the trick.

  8. #8
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Looking for a formula to count single digits vs. double digits?

    i think you need another space in there jb at the front of the range
    =SUM(--(ISNUMBER(SEARCH(" 7,"," "&L105:L287&","))))
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  9. #9
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Looking for a formula to count single digits vs. double digits?

    JB...you can avoid the CSE with this regular formula variation:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  10. #10
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Looking for a formula to count single digits vs. double digits?

    Hehe, go team.

  11. #11
    Registered User
    Join Date
    01-05-2014
    Location
    Minnesota, United States
    MS-Off Ver
    Excel 2011
    Posts
    4

    Re: Looking for a formula to count single digits vs. double digits?

    I simply took and placed a , at the beginning of each cell. ie. , 3, 5, 6, 7, 11 instead of 3, 5, 6, 7, 11. That ended up doing the trick for what I needed. It seems odd that it had to be done that way but so be it.

    Thank you both for your assistance on this. I truly appreciate both of your efforts.

    Have a wonderful New Year, gentlemen.

  12. #12
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Looking for a formula to count single digits vs. double digits?

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  13. #13
    Registered User
    Join Date
    03-29-2023
    Location
    Rhode Island, USA
    MS-Off Ver
    O365
    Posts
    1

    Question Re: Looking for a formula to count single digits vs. double digits?

    Hi when I use the code you provided it works great until I try using it to find "10" it then counts not only "10". but "10.5" as well. Is there an easy fix for this?

    ATTACH]823730[/ATTACH]test 1.xlsx

+ 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. [SOLVED] How to subtract single cells with double digits into a single digit of a single cell.
    By greenfox74 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 03-11-2021, 02:05 AM
  2. Formula to assign letters to digits and repeatedly sum to a single digit
    By nj.astrology in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-11-2014, 01:45 AM
  3. Changing digits after decimal to specific digits based on a criteria
    By mpatel000 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-28-2012, 02:41 AM
  4. .Find problem when the found range's rows go from single to double digits
    By alsega in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-13-2012, 11:21 AM
  5. Lookup Error with Double Digits
    By Niester Rabbit in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-20-2008, 09:42 PM

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