+ Reply to Thread
Results 1 to 17 of 17

Counting or finding formula

  1. #1
    Registered User
    Join Date
    12-15-2013
    Location
    tucson
    MS-Off Ver
    Excel 2010
    Posts
    7

    Counting or finding formula

    I am working on an assignment and i am stuck writing a formula that i need to get done asap.

    I have created a random number generator for a coin toss

    [mycode]=RAND()<.5, "Heads","Tails")[mycode]

    that works fine. so i have that ten times on the same row.

    I need to make a formula that looks at those ten cells and finds if there are four "Heads" in a row and if so than it is a win condition if not then lose condition.


    someone please help me. i do not need the answer i just need to know if theres a formula out there that will help my problem i will do my own work.
    Last edited by hopkins199; 12-15-2013 at 08:31 PM. Reason: forums are too picky

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Need Help ASAP Please.

    Thanks for the title change

    Take a look at using IF() and countif() for this
    Last edited by FDibbins; 12-15-2013 at 08:31 PM.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Need Help ASAP Please.

    Quote Originally Posted by FDibbins View Post
    • We would love to help you with your query
    Except, AFAIK, we generally don't do homework...
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  4. #4
    Registered User
    Join Date
    12-15-2013
    Location
    tucson
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Counting or finding formula

    i am not asking for the answer just need to know what formula i can use to get my own answer. i am glad people think i am looking for a handout. i would have posted the problem if that were the case instead of what i actually posted.

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Counting or finding formula

    Did you see my edit to my 1st post to you?

  6. #6
    Registered User
    Join Date
    12-15-2013
    Location
    tucson
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Counting or finding formula

    yea sorry i am just lost and flustered spending most of my day on this and can't wrap my tired brain around it yet.

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Counting or finding formula

    Understandable

    What have you tried so far?

    countif() syntax is =countif(range-containg-criteria,criteria)

    You would then wrap this in an IF() statement, testing for your requirements

  8. #8
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Counting or finding formula

    countif wont work
    there is a frequency array formula but try explaining that away!
    Last edited by martindwilson; 12-15-2013 at 08:58 PM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  9. #9
    Registered User
    Join Date
    12-15-2013
    Location
    tucson
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Counting or finding formula

    the problem for me is i have ten items of data that i am trying to have it count if their are four of a certain type in that string of ten. then it would comeback as a win. From my limited knowledge of excel trying to have it count four items in a row out of ten seems like a long formula.

  10. #10
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Counting or finding formula

    aahh ok I missed the "4 in a row"

    There is a work-around using a helper column, starting on the 4th value, using countif() based on the above 4 values, copied down

  11. #11
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Counting or finding formula

    use a helper column lets assume you have =IF(RAND()<0.5, "Heads","Tails") in a1:a10
    and then use offset in b1
    you can create a range 4 rows deep from each cell in column a

    =COUNTIF(OFFSET(A1,0,0,4),"heads")=4 you only need to fill that down to b7
    that will check each 4 cells in turn
    a:a4 then a2:a5 ....a7:a10 and return true/false
    you can the do something on that data to see if true is returned i'll leave that for you to figure out but countif or match should what you are looking for

  12. #12
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Counting or finding formula

    yeah ford that seems a bit easier and avoids having to learn offset for now
    might as well spill the beans! try =COUNTIF(A1:A4,"heads") in b4 then see what happens if you fill that down to b10

  13. #13
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Counting or finding formula

    Yup, thats pretty much where I was headed, Martin

  14. #14
    Registered User
    Join Date
    12-15-2013
    Location
    tucson
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Counting or finding formula

    ok i will try to get this working thanks

  15. #15
    Registered User
    Join Date
    12-15-2013
    Location
    tucson
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Counting or finding formula

    ok so if i have to do this many times over how will i use the helper cell. i am supposed to run this 10000 times.

  16. #16
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Counting or finding formula

    so you are going to sit and recalculate the workbook 10000 times?

  17. #17
    Registered User
    Join Date
    12-15-2013
    Location
    tucson
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Counting or finding formula

    thats what i thought thanks for the help everyone this is a good source of information.

+ 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. extracting text string from text file using vba
    By shobit in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-08-2013, 11:48 PM
  2. Please help asap
    By kckid12 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-30-2009, 02:10 AM
  3. Please help asap!!!!!
    By kckid12 in forum Excel General
    Replies: 3
    Last Post: 03-30-2009, 02:09 AM
  4. Need help ASAP! Thanks
    By artromanov in forum Excel General
    Replies: 8
    Last Post: 01-03-2007, 01:36 AM
  5. Need Help ASAP
    By bigwilly11189 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-28-2005, 10:05 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