+ Reply to Thread
Results 1 to 6 of 6

Count number of bar codes

  1. #1
    Registered User
    Join Date
    07-04-2012
    Location
    swindon
    MS-Off Ver
    Excel 2003
    Posts
    26

    Count number of bar codes

    in cell b2 i want to place say 3 bar codes like this 3465 / 8765 / 9087 for example and these codes will change everytime and in cell c2 i want it to count how many that is. so / would separate the codes how would i count this with a formula if poss.

  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: a count if i think?

    With
    A1: containing a delimited list of bar codes (or is blank)...3465 / 8765 / 9087

    If the number of bar codes is equal to the count of "/"+1, try this regular formula:
    B1: =IF(A1<>"",LEN(A1)-SUM(LEN(SUBSTITUTE(A1,"/","")))+1,0)

    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    07-04-2012
    Location
    swindon
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: a count if i think?

    yes for sure thank you it works exactly how i want it to. could i ask what is len?

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

    Re: a count if i think?

    For each non-blank cell in the referenced range, that formula computes the difference between the length_of_the_cell_contents and the length_with_slashes_removed and adds 1.

    The length of: 123/456/789 is 11
    The length of: 123456789 is 9
    So...there are 2 slashes.
    Therefore, there are 3 bar codes

    Does that help?

  5. #5
    Registered User
    Join Date
    07-04-2012
    Location
    swindon
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Count number of bar codes

    ok so if i get it, it is

    =SUM(LEN(C4)-LEN(SUBSTITUTE(C4,"/","")))/LEN("/")+1

    sum length of c4, length substitute c4 / with blank, length +1

    is that correct? i may be being a retard there but i am new to this sort of thing so trying to learn fast and use with great effects

  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: Count number of bar codes

    Actually, I blended two approaches in my post(s).
    With these values in A1:A2
    3465 / 8765 / 9087
    1234 / 5678 / 9012 / 3456

    THIS regular formula returns the count of bar codes in A1
    B1: =LEN(A1)-LEN(SUBSTITUTE(A1,"/",""))+(A1<>"")
    copy that formula into B2

    and this regular formula returns the count of bar codes in A1:A2
    C1: =SUMPRODUCT(LEN(A1:A2)-LEN(SUBSTITUTE(A1:A2,"/",""))+(A1:A2<>""))

    For the sample data
    B1 returns: 3
    B2: returns: 4
    and C1 returns: 7

    I hope that helps.

    This regular formula counts the number of bar codes in A1:A5

+ 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