+ Reply to Thread
Results 1 to 11 of 11

Formula to select value that satisfies conditions

  1. #1
    Registered User
    Join Date
    02-09-2009
    Location
    Winnipeg, Canada
    MS-Off Ver
    Excel 2003
    Posts
    49

    Formula to select value that satisfies conditions

    Need some help to develop a formula that can show me a value if it satisfies 4conditions. Attached is a sheet that shows the data.

    Need a formula that will use column F as a reference to find out if there are 3 previous wins and show the value of FG (H column) and if not it should return just a character ("-" eg). For example in our case the end result should be what is shown in column J. The problem I have is that the sheet contains a break in stats after every 20 games and more conditions have to be added to accomodate this and have not been able to succesfully do it. You can use other columns (as shown) for references if it is easier. See column L for what I have come up with but it does not quite work as I wanted it - as it shows a false where it should return just "-" and also in the row after the last data entry it shows a 0 instead of "-". Table gets updated.

    Any other solution (not using IF function) would be fine as long as I get the end result in column J (as shown).
    Appreciate your help.
    Attached Files Attached Files
    Last edited by VBA Noob; 04-03-2009 at 01:22 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Formula to select value that satisfies conditions

    In J5, try:

    =IF(COUNTIF(F2:F4,"W")>=3,H5,"-") copied down.

    not sure what you mean about:
    The problem I have is that the sheet contains a break in stats after every 20 games and more conditions have to be added to accomodate this
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: Formula to select value that satisfies conditions

    NBVC,
    With your formula, if Game 18,19 and 20 had W in col F, the results in col J would be messed up. See the example attached.
    I have fixed the formula to accomodate for break in the report at Row 25.
    That's what he meant by "break in stats every 20 games".
    modytrane
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    02-09-2009
    Location
    Winnipeg, Canada
    MS-Off Ver
    Excel 2003
    Posts
    49

    Re: Formula to select value that satisfies conditions

    Quote Originally Posted by NBVC View Post
    In J5, try:

    =IF(COUNTIF(F2:F4,"W")>=3,H5,"-") copied down.

    not sure what you mean about:
    Formula works except for 2 cases (which am having trouble with). Refer to the attached sheet for all references:
    1. Row 33 gives result 0 if F32, F31 and F30 are W. Row 33 should have "-" as there are no data on this row.
    2. In row 25 there are no data (again shows name of stats). If 3 W occur and are separated by this row then we have a problem. There are 3 cases where 3 consecutive W can be separated by this "stats name" row and formula has to account for this in order not to miss the data.

    I have attached the sheet again after changing the W and L to reflect this and have also highlighted 2 cells in column K that give the wrong result (should be as shown in column J).
    Hopefully it is a bit clearer now. Let me know if more explanation is required.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    02-09-2009
    Location
    Winnipeg, Canada
    MS-Off Ver
    Excel 2003
    Posts
    49

    Re: Formula to select value that satisfies conditions

    Quote Originally Posted by modytrane View Post
    NBVC,
    With your formula, if Game 18,19 and 20 had W in col F, the results in col J would be messed up. See the example attached.
    I have fixed the formula to accomodate for break in the report at Row 25.
    That's what he meant by "break in stats every 20 games".
    modytrane
    Yes! This does work perfectly. Thanks, Much appreciated.

  6. #6
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: Formula to select value that satisfies conditions

    OK, I took care of all possible conditions [I think].
    look at the example attached. let me know if it works for you.
    modytrane
    Attached Files Attached Files

  7. #7
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Formula to select value that satisfies conditions

    try this :-

    Please Login or Register  to view this content.
    put in row 5 then copy down!

  8. #8
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: Formula to select value that satisfies conditions

    A simpler formula works. Simpler to follow for beginners.


    HTML Code: 

    modytrane

  9. #9
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Formula to select value that satisfies conditions

    My formula was just a starter because I needed the clarification I had asked for...

    but thanks to modytrane for foreseeing it and correcting the problem...

  10. #10
    Registered User
    Join Date
    02-09-2009
    Location
    Winnipeg, Canada
    MS-Off Ver
    Excel 2003
    Posts
    49

    Re: Formula to select value that satisfies conditions

    Quote Originally Posted by modytrane View Post
    A simpler formula works. Simpler to follow for beginners.


    HTML Code: 

    modytrane
    This one works as I would a bit too quick to respond (previous one did not work for some cases) to your earlier post.
    Thanks to NBVC, modytrane, squiggler47 for your quick response.
    Much appreciated.

  11. #11
    Registered User
    Join Date
    02-09-2009
    Location
    Winnipeg, Canada
    MS-Off Ver
    Excel 2003
    Posts
    49

    Re: Formula to select value that satisfies conditions

    Quote Originally Posted by squiggler47 View Post
    try this :-

    Please Login or Register  to view this content.
    put in row 5 then copy down!
    This worked except for 1 case or having 3 W prior to row 25 ("stats name") in this case it returned the stat name as there is no data there. Thanks anyways as it provided an alternative solution which would work with a little tweak (I think).

+ 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