+ Reply to Thread
Results 1 to 3 of 3

Counting digit occurrence in number/column

  1. #1
    Registered User
    Join Date
    03-25-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    10

    Counting digit occurrence in number/column

    Hey all!
    I'm trying to make a VB macro to count the number of times a digit (0-9) occurs in a column. An example is the number 873338 would give 3=3, 7=1, 8=2 all else = 0. Normally i would just use a countif function and avoid VB altogether, but I cant think of a way to break apart the larger number and sum the digit occurrences. Any help would be greatly appreciated!

    Attached is my attempt using countif and 3 pieces of sample data.
    numberCounter.xlsm

  2. #2
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Counting digit occurrence in number/column

    Hello, try this in D6, then copy across

    =SUMPRODUCT(LEN($A1:$A21)-LEN(SUBSTITUTE($A1:$A21,D5,"")))

    Adjust the range.
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  3. #3
    Registered User
    Join Date
    03-25-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Counting digit occurrence in number/column

    Oh wow, that works amazingly, exactly what I needed. Thanks a lot. Could you explain how it works? Always trying to get better.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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