+ Reply to Thread
Results 1 to 9 of 9

If Statements help

  1. #1
    Registered User
    Join Date
    08-22-2009
    Location
    Newmarket, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    3

    If Statements help

    I know how to use very basic If statements, but im stuck here :

    I have a spread sheet where i record 3 outcomes, either "y" (yes) "n" (no) or "l" (late). There are 5 of these a day, I want an if statement to add all of the y's and l's together. For example if one day i had 3 y, 1 L and one N i want the cell with the if statement to show 4 (3y+1L)

    Any help would be appreciated. If you need more explanation let me know, the cells with the y's and n's are B5:F5, outcome cell is G5

    What I have got right now is :

    =IF(B5="y",(1),IF(B5="l",(1),(0)))

    But I have to do this in 5 different cells, anyway i can combine it to do it all in one?
    Last edited by Haris75; 08-24-2009 at 04:33 AM. Reason: missing I in beginning

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: If Statements help

    Try this:

    =COUNTIF($B$5:$F$5,"y") + COUNTIF($B$5:$F$5,"l")

    It's not case-sensitive, either.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: If Statements help

    Or possibly

    =COUNTIF($B$5:$F$5,"<>n")

  4. #4
    Registered User
    Join Date
    08-22-2009
    Location
    Newmarket, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: If Statements help

    Wow thanks to both of you! I had no idea what the COUNTIF was for haha, it looks a lot easier than nesting IF functions.

    And DonkeyOte, can you tell me what the "<>n" is for in =COUNTIF($B$5:$F$5,"<>n") ?

    Edit : nvm i think its saying "anything other than n", right? What if I wanted anything other than "n" as well as blank cells?
    Last edited by Haris75; 08-23-2009 at 05:40 PM. Reason: More help =(

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: If Statements help

    If that takes care of your need, be sure to EDIT your original post, click Go Advanced and mark the PREFIX box [SOLVED].

  6. #6
    Registered User
    Join Date
    08-22-2009
    Location
    Newmarket, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: If Statements help

    Sorry it wasnt, as I said last post

    What if I wanted anything other than "n" as well as blank cells

    in the formula =COUNTIF($B$5:$F$5,"<>n")

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: If Statements help

    What if I wanted anything other than "n" as well as blank cells
    This seems to completely differ from your original post which presented the need to add all the cells in a 5-cell range with a "y" or "l" answer.

    But the answer then goes similarly:
    =5-COUNTIF($B5:$F5,"<>n")
    ...or my original idea, necessary if there is anything other than, y/n/l/blank
    =COUNTIF($B5:$F5,"y") + COUNTIF($B5:$F5,"l") + COUNTIF($B5:$F5,"")

    I've also adjusted the $ symbols so you can copy this formula downward for other rows.

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: If Statements help

    Where the tests are constant you can also convert

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    saves on typing, nothing more.

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: If Statements help

    Please Login or Register  to view this content.
    saves on typing, nothing more.
    Well, there's the neato-factor, too. Some formulas just "look" better, heh. Very nice.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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