+ Reply to Thread
Results 1 to 21 of 21

Win lost draw

  1. #1
    Forum Contributor
    Join Date
    10-27-2013
    Location
    Ireland
    MS-Off Ver
    Microsoft 365
    Posts
    403

    Win lost draw

    How can i calculate the most win draw sequence before a loss so example
    win
    win
    draw
    win
    draw
    loss
    so this answer would be 5, so this be the best run before a loss

    i have win loss draw in column H5:H200 im just trying to figure out the best run before the team lost

    i only want it to be done using the H column this is the Column with the relevant info

    hope ive explained this as best i can

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Win lost draw

    Try this user defined function

    Please Login or Register  to view this content.
    Open the VBA editor by hitting Alt F11.
    Insert a new module with Insert - Module
    Paste in the above function
    Go back to the sheet by hitting Alt F11.

    In a suitable cell, enter = =NoLossRun(H5:H200)

    Remember to save the workbook as a macro enabled workbook .xlsm
    Martin

  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,277

    Re: Win lost draw

    I don't know if this can be done without a "helper" column.

    As an example:

    in I5 put

    =IF(H5="loss",0,I4+1) (I4 must be 0/blank)

    Copy down

    In any cell =MAX(I5:I200) will give longest sequence

    The helper column can be any of your choosing and hidden
    Last edited by JohnTopley; 02-13-2016 at 10:40 AM.

  4. #4
    Forum Contributor
    Join Date
    10-27-2013
    Location
    Ireland
    MS-Off Ver
    Microsoft 365
    Posts
    403

    Re: Win lost draw

    Quote Originally Posted by JohnTopley View Post
    I don't know if this can be done without a "helper" column.

    As an example:

    in I5 put

    =IF(H5="loss",0,I4+1) (I4 must be 0/blank)

    Copy down

    In any cell =MAX(I5:I200) will give longest sequence

    The helper column can be any of your choosing and hidden
    Just in had to go out - John i could use Column H as helper column as it already has Win, Loss or Draw in it these run from h5 to h200

  5. #5
    Forum Contributor
    Join Date
    10-27-2013
    Location
    Ireland
    MS-Off Ver
    Microsoft 365
    Posts
    403

    Re: Win lost draw

    Quote Originally Posted by mrice View Post
    Try this user defined function

    Please Login or Register  to view this content.
    Open the VBA editor by hitting Alt F11.
    Insert a new module with Insert - Module
    Paste in the above function
    Go back to the sheet by hitting Alt F11.

    In a suitable cell, enter = =NoLossRun(H5:H200)

    Remember to save the workbook as a macro enabled workbook .xlsm
    Done this but it gives me exactly what ive got already in H2:h200 it doesnt count just says win, loss draw.

    but thank you

  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: Win lost draw

    What result would you expect if this was your data:

    Loss
    Win
    Win
    Draw
    Win

    What if there aren't any loss entries?

    Win
    Win
    Win
    Draw
    Win
    Last edited by Tony Valko; 02-13-2016 at 12:24 PM.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  7. #7
    Forum Contributor
    Join Date
    10-27-2013
    Location
    Ireland
    MS-Off Ver
    Microsoft 365
    Posts
    403

    Re: Win lost draw

    i need the lost entries as its important that these are in included. currently there is 41 losses

  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: Win lost draw

    You said:

    How can i calculate the most win draw sequence before a loss so example
    It's possible that the longest streak happens AFTER the last Loss...

    Loss
    Win
    Win
    Win
    Draw
    Draw

    The last game played is NOT a Loss so the longest streak is 5. Correct?

    If the NEXT game played is a Loss:

    Loss
    Win
    Win
    Win
    Draw
    Draw
    Loss

    Then the longest streak would still be 5. Correct?

  9. #9
    Forum Contributor
    Join Date
    10-27-2013
    Location
    Ireland
    MS-Off Ver
    Microsoft 365
    Posts
    403

    Re: Win lost draw

    This is correst

  10. #10
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Win lost draw

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 02-13-2016 at 01:46 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  11. #11
    Forum Contributor
    Join Date
    10-27-2013
    Location
    Ireland
    MS-Off Ver
    Microsoft 365
    Posts
    403

    Re: Win lost draw

    Thank you mehmetcik but this only gives me win loss or draw, not giving me winning streak but thank you anyway

  12. #12
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Win lost draw

    Are you sure?

    Check again.

    Try this Data:

    win
    win
    loss
    win
    draw
    win
    win
    win
    win
    draw
    win
    draw
    loss

    Copy paste the Macro into a macro module.

    paste the data into a worksheet

    then use the function to perform the calculation.

    Look at the attached spreadsheet.

    I modifed the function giving you the option to put it at the top of your data ie in A1
    If you use a range say A2 to A200

    then you can type your data in column A and A1 will reflect the latest result.
    Attached Files Attached Files
    Last edited by mehmetcik; 02-13-2016 at 02:41 PM.

  13. #13
    Forum Contributor
    Join Date
    10-27-2013
    Location
    Ireland
    MS-Off Ver
    Microsoft 365
    Posts
    403

    Re: Win lost draw

    What exactly do i need to copy from? i copies this Function NoLossRun(MyRange As Range) and all the code down until an including End Function
    trying again now

  14. #14
    Forum Contributor
    Join Date
    10-27-2013
    Location
    Ireland
    MS-Off Ver
    Microsoft 365
    Posts
    403

    Re: Win lost draw

    the ones in colour are my own the plain ones are from the suggested reply but thank you
    seq.PNG

  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: Win lost draw

    See if this does what you want...

    Data Range
    H
    I
    J
    5
    Loss
    Longest Streak
    6
    Win
    6
    7
    Loss
    8
    Win
    9
    Win
    10
    Win
    11
    Win
    12
    Loss
    13
    Draw
    14
    Draw
    15
    Draw
    16
    Win
    17
    Draw
    18
    Win
    19
    Loss
    20
    Draw
    21
    ------
    ------
    ------


    This array formula** entered in J6:

    =MAX(FREQUENCY(IF(ISNUMBER(MATCH(H5:H20,{"Win","Draw"},0)),ROW(H5:H20)),IF(H5:H20="Loss",ROW(H5:H20))))

    ** 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.

  16. #16
    Forum Contributor
    Join Date
    10-27-2013
    Location
    Ireland
    MS-Off Ver
    Microsoft 365
    Posts
    403

    Re: Win lost draw

    Quote Originally Posted by Tony Valko View Post
    See if this does what you want...

    Data Range
    H
    I
    J
    5
    Loss
    Longest Streak
    6
    Win
    6
    7
    Loss
    8
    Win
    9
    Win
    10
    Win
    11
    Win
    12
    Loss
    13
    Draw
    14
    Draw
    15
    Draw
    16
    Win
    17
    Draw
    18
    Win
    19
    Loss
    20
    Draw
    21
    ------
    ------
    ------


    This array formula** entered in J6:

    =MAX(FREQUENCY(IF(ISNUMBER(MATCH(H5:H20,{"Win","Draw"},0)),ROW(H5:H20)),IF(H5:H20="Loss",ROW(H5:H20))))

    ** 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.
    Thank you John this is working perfectly and thank you to all that have made other suggestions as well ye are brill

  17. #17
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,277

    Re: Win lost draw

    Thanks are due to Tony not myself.

  18. #18
    Forum Contributor
    Join Date
    10-27-2013
    Location
    Ireland
    MS-Off Ver
    Microsoft 365
    Posts
    403

    Re: Win lost draw

    Quote Originally Posted by Tony Valko View Post
    See if this does what you want...

    Data Range
    H
    I
    J
    5
    Loss
    Longest Streak
    6
    Win
    6
    7
    Loss
    8
    Win
    9
    Win
    10
    Win
    11
    Win
    12
    Loss
    13
    Draw
    14
    Draw
    15
    Draw
    16
    Win
    17
    Draw
    18
    Win
    19
    Loss
    20
    Draw
    21
    ------
    ------
    ------


    This array formula** entered in J6:

    =MAX(FREQUENCY(IF(ISNUMBER(MATCH(H5:H20,{"Win","Draw"},0)),ROW(H5:H20)),IF(H5:H20="Loss",ROW(H5:H20))))

    ** 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.
    My mistake Thank you Tony and to all

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

    Re: Win lost draw

    You're welcome. We appreciate the feedback!

    If your question has been solved please mark the thread as being solved.

    In the menu bar above the very first post select Thread Tools, then select Mark this thread as solved.

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

    Re: Win lost draw

    Quote Originally Posted by JohnTopley View Post
    I don't know if this can be done...
    I learned a long time ago that I should not post thoughts like that as someone would surely prove me wrong (and they did!).

    I may still think that but I just keep it to myself until all the evidence is in!

  21. #21
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,277

    Re: Win lost draw

    @Tony,
    As a genuine guru, you have much more to "lose" than me by making such a statement! I am far too old to worry about such things, nor do I have any reputation to lose. I am merely a foot soldier and know my limitations!!
    Last edited by JohnTopley; 02-14-2016 at 09:33 AM.

+ 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. Cup Draw
    By Happyman123uk in forum Excel General
    Replies: 3
    Last Post: 12-08-2015, 02:19 PM
  2. Lost spaces and Zeros lost when replacing text
    By renshawk in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-29-2013, 04:50 AM
  3. anyone know how to draw a range?
    By yellowpower in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 01-19-2011, 06:44 AM
  4. VBA to draw a box
    By jamesstorx in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-05-2010, 07:12 PM
  5. Cup Draw
    By Sheepkin_Coat in forum Excel General
    Replies: 6
    Last Post: 06-03-2009, 03:48 PM
  6. [SOLVED] How do I keep a running total of pounds lost and percentage lost
    By angel5959 in forum Excel General
    Replies: 4
    Last Post: 01-26-2006, 05:20 PM

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