+ Reply to Thread
Results 1 to 10 of 10

IF statement to display Quarter of a year based on a three-letter month abbreviation

  1. #1
    Registered User
    Join Date
    11-11-2009
    Location
    Washington, DC
    MS-Off Ver
    Excel 2007
    Posts
    19

    IF statement to display Quarter of a year based on a three-letter month abbreviation

    Hey guys, I'm trying to wrtie an IF statement to display one of Q1, Q2, Q3 or Q4 based on the three letter month abbrev. All i have so far is the following, which isn't leading anywhere - and i have a feeling theres an easier way to write it. Thanks!

    =IF(((OR(G2="Jan","Feb","Mar"),)),"Q1",""),IF(OR(G2="Apr","May","Jun"),"Q2","")

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: IF statement to display Quarter of a year based on a three-letter month abbreviat

    wrong application of OR()

    =IF(OR(G2="Jan",G2="Feb",G2="Mar"),"Q1",IF(OR(G2="Apr",G2="May",G2="Jun"),"Q2",""))

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

    Re: IF statement to display Quarter of a year based on a three-letter month abbreviat

    if you just put a real month in cell g2 eg 01/jan/2009 format cell as mmm
    then
    ="Q"&CEILING(MONTH(g2)/3,1)
    OR with text
    ="Q"&IF(OR(G2={"jan","feb","mar"}),1,IF(OR(G2={"apr","may","jun"}),2,IF(OR(G2={"jul","aug","sep"}),3,4)))
    Last edited by martindwilson; 11-16-2009 at 07:13 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

  4. #4
    Registered User
    Join Date
    11-11-2009
    Location
    Washington, DC
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: IF statement to display Quarter of a year based on a three-letter month abbreviat

    Ok, thanks. Still trying to learn a lot of the functions as i've never used most of them, even the basic ones like OR.

  5. #5
    Registered User
    Join Date
    11-11-2009
    Location
    Washington, DC
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: IF statement to display Quarter of a year based on a three-letter month abbreviat

    Ok, ill try that formula too. Its two steps. The original cell will have a date in it, and another cell will convert that to just the three letter abbrev, then the quarter, which i couldnt do.

  6. #6
    Forum Expert darkyam's Avatar
    Join Date
    03-05-2008
    Location
    Houston, TX
    MS-Off Ver
    2013
    Posts
    2,191

    Re: IF statement to display Quarter of a year based on a three-letter month abbreviat

    Here's one way: ="Q"&INT((MATCH(G2,{"Jan";"Feb";"Mar";"Apr";"May";"Jun";"Jul";"Aug";"Sep";"Oct";"Nov";"Dec"},0)-1)/3)+1

  7. #7
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: IF statement to display Quarter of a year based on a three-letter month abbreviat

    Please Login or Register  to view this content.
    Where A1 is the abreviation "Jan", "Feb" etc

    And Months refers to ={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  8. #8
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: IF statement to display Quarter of a year based on a three-letter month abbreviat

    With the 3 letter abbreviation in G2 you can get the quarter with this formula

    ="Q"&INT((MONTH(1&G2)+2)/3)

  9. #9
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: IF statement to display Quarter of a year based on a three-letter month abbreviat

    You can use OR similar to what you had thought, but not exactly.

    =IF(OR(G2={"Jan","Feb","Mar"}),"Q1",IF(OR(G2={"Apr","May","Jun"}),"Q2",IF(OR(G2={"Jul","Aug","Sep"}),"Q3","Q4")))

    Another option, so there's only one test, would be to use:

    ="Q"&LOOKUP(G2,{"Apr","Aug","Dec","Feb","Jan","Jul","Jun","Mar","May","Nov","Oct","Sep"},{2,3,4,1,1,3,2,1,2,4,4,3})

  10. #10
    Registered User
    Join Date
    11-11-2009
    Location
    Washington, DC
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: IF statement to display Quarter of a year based on a three-letter month abbreviat

    Thanks for all the suggestions! They all work great and now i can try and apply/learn what they actually mean instead of just copying.

+ 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