+ Reply to Thread
Results 1 to 17 of 17

Lottery Filter#1, SUM in Single CELL with "-"

  1. #1
    Forum Contributor
    Join Date
    10-21-2012
    Location
    miami, florida usa
    MS-Off Ver
    Excel 2007
    Posts
    260

    Lottery Filter#1, SUM in Single CELL with "-"

    Hi

    I have been using a "SUM" formula to determine the last time a number appeared in the lottery draws,
    but i been doing when a number is in single Cell.

    But now i trying to SUM Combination of Pick 5 or 6 numbers with "-" (01-02-03-04-05) lottery numbers with in Single Cell, and i can't find help.
    (Numbers are aprox 2500 to 3600 in a Single Cell each Pick )

    Example :
    Please Login or Register  to view this content.
    I need to get the total Sum on Column H

    Is there a way to do this with function formula?



    Thanks in advance

    David.

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

    Re: Lottery Filter#1, SUM in Single CELL with "-"

    Try this...

    Data Range
    G
    H
    6
    22-33-34-35-36
    160
    7
    08-28-29-30-35
    130
    8
    01-18-23-33-35
    110

    This array formula** entered in H6 and copied down:

    =SUM(IF(MID("-"&G6,COLUMN(1:1),1)="-",--(0&MID(G6,COLUMN(1:1),FIND("-",G6&"-",COLUMN(1:1))-COLUMN(1:1)))))

    ** 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.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,320

    Re: Lottery Filter#1, SUM in Single CELL with "-"

    =VALUE(LEFT(G6,2)+MID(G6,4,2)+MID(G6,7,2)+MID(G6,10,2)+RIGHT(G6,2))
    Try this one
    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

  4. #4
    Forum Contributor
    Join Date
    11-10-2012
    Location
    istanbul
    MS-Off Ver
    Excel 2013
    Posts
    297

    Re: Lottery Filter#1, SUM in Single CELL with "-"

    See attached file.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    10-21-2012
    Location
    miami, florida usa
    MS-Off Ver
    Excel 2007
    Posts
    260

    Re: Lottery Filter#1, SUM in Single CELL with "-"

    Hi Mr Tony Valko, it work good!!

    at the beginning on H6 i was getting 22, But was my fault..

    Thank you Sir

  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: Lottery Filter#1, SUM in Single CELL with "-"

    You're welcome. Thanks for the feedback!

    If the numbers will ALWAYS be 2 digit numbers you'd be better off using something simpler like that in post #3.

  7. #7
    Forum Contributor
    Join Date
    10-21-2012
    Location
    miami, florida usa
    MS-Off Ver
    Excel 2007
    Posts
    260

    Re: Lottery Filter#1, SUM in Single CELL with "-"

    Hi Mr turist,

    Thanks, it's a nice database, i' m checking the macro..


    David

  8. #8
    Forum Contributor
    Join Date
    10-21-2012
    Location
    miami, florida usa
    MS-Off Ver
    Excel 2007
    Posts
    260

    Re: Lottery Filter#1, SUM in Single CELL with "-"

    Hi Mr popipipo,

    Unfortunately i have #VALUE Error, i don't know why, but thank you so much because you try ed,
    i already paste mr valko formula and is working.

    David

  9. #9
    Forum Contributor
    Join Date
    10-21-2012
    Location
    miami, florida usa
    MS-Off Ver
    Excel 2007
    Posts
    260

    Re: Lottery Filter#1, SUM in Single CELL with "-"

    Hi Mr Tony Valko,

    Now i got it, To sum a group of numbers with in single cell i have to use the LEFT,MID,RIGHT Formula?
    I my god, no wonder i have had a hard time..

    Thank you

  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: Lottery Filter#1, SUM in Single CELL with "-"

    Try this tweak to popipipo's formula.

    =LEFT(G6,2)+MID(G6,4,2)+MID(G6,7,2)+MID(G6,10,2)+RIGHT(G6,2)

  11. #11
    Forum Contributor
    Join Date
    10-21-2012
    Location
    miami, florida usa
    MS-Off Ver
    Excel 2007
    Posts
    260

    Re: Lottery Filter#1, SUM in Single CELL with "-"

    Hi Mr Valko,
    The
    Please Login or Register  to view this content.
    It doesn't work, i still getting a #VALUE error..

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

    Re: Lottery Filter#1, SUM in Single CELL with "-"

    Worked OK for me.

    Can you post the example where it returns that error?

  13. #13
    Forum Contributor
    Join Date
    10-21-2012
    Location
    miami, florida usa
    MS-Off Ver
    Excel 2007
    Posts
    260

    Re: Lottery Filter#1, SUM in Single CELL with "-"

    Hi Mr Tony Valko,

    I'm sorry, i was busy.

    Please, here is the file example : https://dl.dropboxusercontent.com/u/...arch-Tool.xlsm

    Thanks

  14. #14
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Lottery Filter#1, SUM in Single CELL with "-"

    awesome formula, Tony. i didn't think it was possible to sum those values, except to extract parts by parts painfully using LEFT, RIGHT & MID. for this case of course, it will be slightly easier. but Tony's formula comes in really handy with longer combinations or with a non fixed structure of 2 digits each. totally going into my compilation & here's my attempt in explaining it to help the OP understand too:

    ="-"&G6
    1 character after the "-" is where the numbers to add up are. see first dash, add 33. see second dash, add 34, & so on. but the first number is missed out because there is no dash in front of 22. hence, the formula first adds a "-" to G6 so that all are equal.

    =COLUMN(1:1)
    COLUMN(A1) returns 1. that's the column number of A1. COLUMN B1 returns 2. if you use COLUMN(A1:C1), it returns all the column numbers in that range like this:
    {1,2,3}
    COLUMN(1:1) will therefore return 1 to 16,384 if you are using xlsx extension (up to Column XFD)

    =MID("-"&G6,COLUMN(1:1),1)
    this part is to break up all the characters into parts of 1 each. so since we combined "-" with G6, we are looking at this text below:
    "-22-33-34-35-36"
    and in here, it's saying, from that text above, start from the 1st character (using COLUMN), and 1 character long. but since COLUMN was used, it continues to extract form the 2nd character, 3rd character & so on until 16,384 characters. the results are something like:{"-","2","2","-","3","3","-","3","4","-","3","5","-","3","6","","","",..........}

    MID("-"&G6,COLUMN(1:1),1)="-"
    this is to check if the extraction is a "-". so only if it is a "-", the formula will do a MID formula extraction in the next part. it will become TRUEs & FALSEs:
    {TRUE,FALSE,FALSE,TRUE,FALSE,FALSE,TRUE,FALSE,FALSE,TRUE,FALSE,FALSE,TRUE,FALSE,FALSE,...............}

    =FIND("-",G6&"-",COLUMN(1:1))-COLUMN(1:1)
    FIND is used to find a dash in this text below using G6 combined with a dash behind.
    "22-33-34-35-36-"
    the start_num of FIND is also used using COLUMN(1:1). 1 is simply to start finding "-" in the 1st character. that will return 3. if i were to start finding in the 4th character, the next "-" is in character 6. at the end the formula, it minus 1 character for the 1st extraction using COLUMN(1:1). so 3-1 is 2. 6 would be deducting 4, because we're doing the when we start finding in the 4th character, COLUMN would become 4. so it's always 2 characters for this case. it will roughly look like:
    {2,1,0,2,1,0,2,1,0,2,1,0,2,1,0,#VALUE!,#VALUE!,......}
    VALUE error is due to "-" not being found any more after 15 characters.

    =MID(G6,COLUMN(1:1),FIND("-",G6&"-",COLUMN(1:1))-COLUMN(1:1))
    the first extraction would be from the text in G6, start from the 1st character (using COLUMN again). and the number of characters 2 since FIND returns that. that gives us 22 (the 1st number we want to add).
    the 4th extraction would again be from text in G6, starting from 4th character (since COLUMN will give 4) & a length of 2 characters again, obtained by FIND. that gives us 33 (the 2nd number we want to add).
    in summary:
    {"22","2","","33","3","","34","4","","35","5","","36","6","",#VALUE!,#VALUE!,#VALUE!}
    2 things here; these numbers are actually texts with the double quotes. hence we can't add them up. also, notice that we don't want some of those numbers, namely the 2nd, 3rd, 5th, 6th, etc numbers.

    =--(0&MID(G6,COLUMN(1:1),FIND("-",G6&"-",COLUMN(1:1))-COLUMN(1:1)))
    adding the double negatives will make all the texts inside the brackets numbers, if they are indeed are numbers. the 0& is to add a 0 in front of those numbers. not sure why is that necessary. maybe Tony can explain this

    =SUM(IF(MID("-"&G6,COLUMN(1:1),1)="-",--(0&MID(G6,COLUMN(1:1),FIND("-",G6&"-",COLUMN(1:1))-COLUMN(1:1)))))
    using the logical test we did in the inital stage, we can extract those numbers ONLY IF the single character we extracted are the "-".
    Last edited by benishiryo; 10-15-2013 at 10:10 AM. Reason: grammar correction

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

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

    Re: Lottery Filter#1, SUM in Single CELL with "-"

    OK, the problem is that the number strings in column G have 9 trailing space characters. Like this:

    22-33-34-35-36[sp|sp|sp|sp|sp|sp|sp|sp|sp]

    So, you can use this more efficient formula in H6:

    =IF(G6="","",LEFT(G6,2)+MID(G6,4,2)+MID(G6,7,2)+MID(G6,10,2)+RIGHT(TRIM(G6),2))

    And this formula in I6:

    =IF(H6="","",LEFT(H6)+MID(H6,2,1)+IF(LEN(H6)=3,RIGHT(H6),0))

    Copy down as needed.

    You'll notice that there is no longer the "delay" when entering data.

    If the number strings in column G come from an external source you can "clean" those trailing spaces by using this macro:

    http://www.mvps.org/dmcritchie/excel/join.htm#trimall

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

    Re: Lottery Filter#1, SUM in Single CELL with "-"

    Improvements...

    Entered in H6:

    =IF(G6="","",SUM(--MID(G6,{1,4,7,10,13},2)))

    Entered in I6:

    =IF(H6="","",SUM(--MID(H6&0,{1,2,3},1)))


  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: Lottery Filter#1, SUM in Single CELL with "-"

    One more:

    In Name Manager, create a new name, say Lottery_Sum, and type this in the Refers to: box:

    =-EVALUATE("-"&Sheet1!$G6)

    Exit Name Manager. Then, in H6, enter:

    =Lottery_Sum

    Copy down as required.

    Regards
    Click * below if this answer helped

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

+ 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] Count "A" and "V" as separate characters in a single cell
    By sportboy712 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-04-2013, 12:26 PM
  2. Replies: 2
    Last Post: 08-02-2011, 06:57 AM
  3. Replies: 4
    Last Post: 01-21-2008, 08:22 AM
  4. "Criteria Range" in the "Data/Filter/Advanced Filter" to select Du
    By TC in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-11-2005, 10:06 PM
  5. Replace text "Smith, Joe" into "Joe Smith" for a single cell
    By flyingmachine in forum Excel General
    Replies: 6
    Last Post: 04-07-2005, 02:53 PM

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