+ Reply to Thread
Results 1 to 13 of 13

How to count numbers in cells where several numbers are separated by /

  1. #1
    Registered User
    Join Date
    07-03-2014
    Location
    Antwerp, Belgium
    MS-Off Ver
    MS Office 2010
    Posts
    10

    How to count numbers in cells where several numbers are separated by /

    Hi,

    I have multiple cells with data like this: 6541/345/4862/13 in Cell A1, 1235/489/2136/59 in Cell A2 ...

    Is there a formula to count only the "third" part of each cell?

    In this example 4862 + 2136?

    Anyone with a solution?
    Thanks

  2. #2
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: How to count numbers in cells where several numbers are separated by /

    What is it you are trying to count? How many numbers in 4682? Or you want to SUM 4682 from A1 and 2136 from A2?
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  3. #3
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: How to count numbers in cells where several numbers are separated by /

    Alkey is right. You have not explained your requirement clearly.

    So see if this helps.
    Assuming your string is in A1, then

    If you just want to return the third number in the string, try this in B1
    Please Login or Register  to view this content.
    If you want B1 to show the number of digits in the third number of the string, try this in B1
    Please Login or Register  to view this content.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  4. #4
    Registered User
    Join Date
    07-03-2014
    Location
    Antwerp, Belgium
    MS-Off Ver
    MS Office 2010
    Posts
    10

    Re: How to count numbers in cells where several numbers are separated by /

    I'm so sorry.

    I mean I want to sum up the numbers.
    So make the sum of each third part of the cell.
    But keep in mind that this number is anywhere from 1 tot 5 digits.

  5. #5
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: How to count numbers in cells where several numbers are separated by /

    If you show an example with data and the expected output it would become even more clear.
    <----- If you were helped by my posts you can say "Thank you" by clicking the star symbol down to the left

    If the problem is solved, finish of the thread by clicking SOLVED under Thread Tools
    I don't wish to leave you with no answer, yet I sometimes miss posts. If you feel I forgot you, remind me with a PM or just bump the thread.

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: How to count numbers in cells where several numbers are separated by /

    Assuming there will always be 4 delimited numbers per cell...

    Data Range
    A
    B
    1
    6541/345/4862/13
    7198
    2
    1235/489/2136/59
    3
    41887/20/200/100


    This array formula** entered in B1:

    =SUM(--TRIM(LEFT(RIGHT(SUBSTITUTE(A1:A3,"/",REPT(" ",100)),200),100)))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.
    Last edited by Tony Valko; 07-03-2014 at 03:46 PM.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  7. #7
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: How to count numbers in cells where several numbers are separated by /

    Quote Originally Posted by Tony Valko View Post
    This array formula** entered in B1:

    =SUM(--TRIM(LEFT(RIGHT(SUBSTITUTE(A1:A3,"/",REPT(" ",100)),200),100)))
    Just a point, but that'll work equally well non-CSE with SUMPRODUCT.

    Cheers.
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: How to count numbers in cells where several numbers are separated by /

    Yes, so let's use this opportunity to look at the myth that array formulas are slower than normally entered formulas.

    Tested these 2 formulas:

    Array entered**:

    =SUM(--TRIM(LEFT(RIGHT(SUBSTITUTE(A1:An,"/",REPT(" ",100)),200),100)))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

    Normally entered:

    =SUMPRODUCT(--TRIM(LEFT(RIGHT(SUBSTITUTE(A1:An,"/",REPT(" ",100)),200),100)))

    Here are the calculation times (in seconds):

    Data Range
    C
    D
    E
    F
    G
    H
    I
    1
    100 rows
    Test1
    Test2
    Test3
    Test4
    Test5
    Average
    2
    SUM array
    0.00070
    0.00071
    0.00070
    0.00071
    0.00070
    0.00070
    3
    SUMPRODUCT
    0.00071
    0.00070
    0.00070
    0.00070
    0.00070
    0.00070
    4
    5
    1000 rows
    Test1
    Test2
    Test3
    Test4
    Test5
    Average
    6
    SUM array
    0.00535
    0.00541
    0.00551
    0.00536
    0.00536
    0.00540
    7
    SUMPRODUCT
    0.00547
    0.00541
    0.00537
    0.00537
    0.00541
    0.00541


    Used Charles Williams' range timer code which can be found here:

    http://msdn.microsoft.com/en-us/library/aa730921.aspx
    Last edited by Tony Valko; 07-03-2014 at 08:08 PM. Reason: corrected the URL

  9. #9
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: How to count numbers in cells where several numbers are separated by /

    I don't think that the speed is an issue. It is the system resources that required to process array calculations which in turn may slow the entire calculation process down. What is more interesting is that Microsoft's recommendation to use SUMPRODUCT function when possible because "it is slightly faster than the equivalent array formula".

    http://msdn.microsoft.com/en-us/libr...rraySumProduct

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: How to count numbers in cells where several numbers are separated by /

    Quote Originally Posted by AlKey View Post
    It is the system resources that required to process array calculations which in turn may slow the entire calculation process down.
    Which is why the results you get on your machine may be different than the results I get on my machine.

    use SUMPRODUCT function when possible because "it is slightly faster than the equivalent array formula".
    Well, that wasn't the case in this application.
    Last edited by Tony Valko; 07-04-2014 at 08:42 AM. Reason: added the missing word: the!

  11. #11
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: How to count numbers in cells where several numbers are separated by /

    Actually I tend to prefer SUMPRODUCT when possible, not because I believe it is necessarily "faster" than the equivalent CSE version, but simply as it avoids potential issues re the OP coming back having obviously failed to heed the large, emboldened, asterisked instructions re array formulas that I include!

    Cheers

  12. #12
    Registered User
    Join Date
    07-03-2014
    Location
    Antwerp, Belgium
    MS-Off Ver
    MS Office 2010
    Posts
    10

    Re: How to count numbers in cells where several numbers are separated by /

    Oke.

    Thanks a lot for all the replies.
    =SUM(--TRIM(LEFT(RIGHT(SUBSTITUTE(A1:An,"/",REPT(" ",100)),200),100))) seems to work for a fix number of cells.

    But the thing is, I want to be able to edit and work with the cells.
    I'll give more clarification:

    CarAval.jpg

    On the image, in the red box on the right, I want the sum of all the third parts of each cell in the red circle in the first cell (next to 1)
    The same for 2, 3 and 4.
    The first partof a cell is always 4 digits, the second always 3 and the last is always a date, so 8 digits.

    I also want to be able to drag cells across the sheet, and the table will change as well.

    If you need further clarification, don't hesitate because I'm fairly new to the world of forums

  13. #13
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: How to count numbers in cells where several numbers are separated by /



    Can you post a SMALL sample that shows us what results you expect?

    A SMALL file is one where we don't have to scroll to see the data!

+ 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. how to count occurence of numbers separated by , in a single cell
    By Harlan Grove in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 09-06-2005, 04:05 AM
  2. [SOLVED] how to count occurence of numbers separated by , in a single cell
    By kish20 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  3. how to count occurence of numbers separated by , in a single cell
    By kish20 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 01:05 AM
  4. [SOLVED] Count comma separated numbers, numbers in a range with dash, not t
    By Mahendra in forum Excel General
    Replies: 0
    Last Post: 08-08-2005, 01:05 PM
  5. how to count occurence of numbers separated by , in a single cell
    By kish20 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-10-2005, 03:05 AM

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