+ Reply to Thread
Results 1 to 8 of 8

If Statement: “Starts With”

Hybrid View

  1. #1
    Registered User
    Join Date
    07-26-2010
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    23

    If Statement: “Starts With”

    I’m having trouble writing an if statement that tests whether or not a cell starts with a certain value. Here’s the outcome I’m trying to produce:

    If A1 starts with 1/, 2/, or 3/, then insert “Q1”
    If A1 starts with 4/, 5/, or 6/, then insert “Q2”
    If A1 starts with 7/, 8/, or 9/ then insert “Q3”
    If A1 starts with 10/, 11/, or 12/, then insert “Q4”

    How do I make one if statement that combines these stipulations?

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

    Re: If Statement: “Starts With”

    Is A1 a date? (not a text representation of a date). If so then you could use a formula like this

    ="Q"&MATCH(MONTH(A1),{1,4,7,10})
    Audere est facere

  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: “Starts With”

    if its text
    =CHOOSE(CEILING(LEFT(A1,(FIND("/",A1)-1))/3,1),"Q1","Q2","Q3","Q4")
    or just
    ="Q"&CHOOSE(CEILING(LEFT(A1,(FIND("/",A1)-1))/3,1),1,2,3,4)
    "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
    07-26-2010
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: If Statement: “Starts With”

    Hi dll,

    It is indeed, and your formula works perfectly!! Thanks so much for your quick and accurate help

  5. #5
    Registered User
    Join Date
    07-26-2010
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: If Statement: “Starts With”

    martin, yours also works flawlessly. thanks, guys!

  6. #6
    Registered User
    Join Date
    07-26-2010
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: If Statement: “Starts With”

    If I want it to display the year as well (such as 2010 Q3), how would I modify the code?

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: If Statement: “Starts With”

    =year(a1) & " q" & match(month(a1),{1,4,7,10})
    Entia non sunt multiplicanda sine necessitate

  8. #8
    Registered User
    Join Date
    07-26-2010
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: If Statement: “Starts With”

    shg, that works :D

+ 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