+ Reply to Thread
Results 1 to 17 of 17

How to calculate a sequecnce of numbers in a single cell separted by commas and dashes

  1. #1
    Registered User
    Join Date
    10-17-2013
    Location
    Texas
    MS-Off Ver
    Excel 2003
    Posts
    9

    How to calculate a sequecnce of numbers in a single cell separted by commas and dashes

    Is there a way to count numbers in a cell separated by commas but also by a range ( dashes) ? for example:


    Tx# (H10) Total (I10)
    _____ ____
    1,2,3,4,5-10 9


    So that a person does not have to enter 1,2,3,4,5,6,7,8,9,10 It would just count the span?


    The formula I currently have to calcualte them separated by commas is :

    =if(SUMPRODUCT((LEN(H10)-LEN(SUBSTITUTE(H10,",",""))))=0,if(count(H10)=1,sumproduct((len(H10)-LEN(substitute(H10,",",""))+1)),"0"),sumproduct((len(H10)-len(substitute(H10,",",""))+1)))

  2. #2
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: How to calculate a sequecnce of numbers in a single cell separted by commas and dashes

    Hi
    Assuming A1 contains the list of numbers you could use this formula:

    =(LEN(A1)-LEN(SUBSTITUTE(A1, ",",""))+1)+(LEN(A1)-LEN(SUBSTITUTE(A1, "-","")))

    Good luck.
    Tony

  3. #3
    Registered User
    Join Date
    10-17-2013
    Location
    Texas
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: How to calculate a sequecnce of numbers in a single cell separted by commas and dashes

    Hi thanks for responding. I'm honestly a little slow when it comes to this. Would this be an addition to my formula I already have listed?

  4. #4
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: How to calculate a sequecnce of numbers in a single cell separted by commas and dashes

    Hi
    No, replace your formula with this one.
    Tony

  5. #5
    Registered User
    Join Date
    10-17-2013
    Location
    Texas
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: How to calculate a sequecnce of numbers in a single cell separted by commas and dashes

    Ok I do not find that it works. It shows the value as one for the sequence

    1,3,4,5,9-20,5

  6. #6
    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 calculate a sequecnce of numbers in a single cell separted by commas and dashes

    Hi,

    What should the result be for the sequence:

    1,3,4,5,9-20,5 ?

    So sequences do not have to be in numerical order (the 5 at the end suggests such)?

    Does the 5 get counted twice (and would it get counted a third time, if e.g the string 2-8 also appeared in the list)?

    Regards
    Click * below if this answer helped

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

  7. #7
    Registered User
    Join Date
    10-17-2013
    Location
    Texas
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: How to calculate a sequecnce of numbers in a single cell separted by commas and dashes

    Yes. Most likely the numbers in the cell will not duplicate as in my example.. as my staff should be working by sequence in a particular invoice. For example they are working transactions Number 1,3,4,5,9-20
    under Invoice Number 5463587


    The result should be Total number of Transactions worked should equal to 16 number of transactions worked for that Invoice

  8. #8
    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 calculate a sequecnce of numbers in a single cell separted by commas and dashes

    Actually, come to think of it, how do you arrive at an answer of 9 for the count of numbers in the sequence:

    1,2,3,4,5-10 ?

    Surely there are 10? Or am I missing something here?

    Regards

  9. #9
    Registered User
    Join Date
    10-17-2013
    Location
    Texas
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: How to calculate a sequecnce of numbers in a single cell separted by commas and dashes

    No you are correct there are 10. My mistake. I already explained I'm a little slow..lol

  10. #10
    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 calculate a sequecnce of numbers in a single cell separted by commas and dashes

    Hi,

    Assuming your list begins in cell A1, with B1 the active cell (important), go to Name Manager and define a new name, Count_Numbers, say, and enter this in the Refers to: box:

    =EVALUATE(SUBSTITUTE(SUBSTITUTE("ROWS("&Sheet1!A1,",",")+ROWS("),"-",":")&")")

    Exit Name Manager. Then, in cell B1, enter this formula:

    =Count_Numbers

    Copy down as required.

    Regards

  11. #11
    Registered User
    Join Date
    10-17-2013
    Location
    Texas
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: How to calculate a sequecnce of numbers in a single cell separted by commas and dashes

    I don't know how you know all of this..but Thanks a lot. My last question in regards to this would be how do you make sure the value is zero for boxes that are empty? I put in the formula and it calculated them correctly in B1 lets say..but to total all the transactions at the bottom it's saying Value ..because now my sum formula doesn't work

  12. #12
    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 calculate a sequecnce of numbers in a single cell separted by commas and dashes

    No worries.

    Just change the formula in B1 to:

    =IF(A1="",0,Count_Numbers)

    Regards

  13. #13
    Registered User
    Join Date
    10-17-2013
    Location
    Texas
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: How to calculate a sequecnce of numbers in a single cell separted by commas and dashes

    You're a LIFE SAVER.. Thanks so Much !!! Have a great Day!!

  14. #14
    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 calculate a sequecnce of numbers in a single cell separted by commas and dashes

    You're welcome!!

  15. #15
    Registered User
    Join Date
    10-17-2013
    Location
    Texas
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: How to calculate a sequecnce of numbers in a single cell separted by commas and dashes

    Ok I lied. One last question. When I go down the sheet. For example If the span is 1,2,3,4,5,6,7,8,9,10 and I enter 1-10 it converts it to a date. Anything that starts with 1-12 ( for the 12 calendar months) converts it to a date. Is there a way around this?

  16. #16
    Registered User
    Join Date
    10-17-2013
    Location
    Texas
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: How to calculate a sequecnce of numbers in a single cell separted by commas and dashes

    I didn't lie about you being a life saver..lol.. just that I only had one more question!

  17. #17
    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 calculate a sequecnce of numbers in a single cell separted by commas and dashes

    Sure. Put a single apostrophe (') in the cell before you start typing.

    Cheers

+ 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. Replies: 5
    Last Post: 01-17-2014, 05:56 PM
  2. [SOLVED] 2 separate columns with numbers separated by commas and single numbers not, need sum
    By Slothbob in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-22-2013, 04:33 PM
  3. Multiple numbers seperated by commas in a single cell
    By abe10 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-26-2013, 05:42 PM
  4. Is there a way to remove all the commas and dashes in a set of data in excel?
    By mukori in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-19-2012, 04:32 PM
  5. Replies: 2
    Last Post: 08-16-2011, 09:03 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