+ Reply to Thread
Results 1 to 5 of 5

Checking a cell for a value then adding months/years to a date in a second column

  1. #1
    Registered User
    Join Date
    12-07-2009
    Location
    Washington, DC
    MS-Off Ver
    excel 2007
    Posts
    5

    Checking a cell for a value then adding months/years to a date in a second column

    I am trying to create an IF statement that will check column a2 for a value (y or n). If the value is y, then I need to add 75 months (6 years and 3 months) to the date in column b2. If the value is n, then I need to only add 36 months to the date in column b2. The new date will be stored in column c2 in either instance. Attached is an example of what I have so far.

    The IF statement that I came up with is:

    IF(a2="y", c2.value=Date(Year(b2),Month(B2)+75,Day(b2)), [c2.value=Date(Year(b2),Month(b2)+36,Day(b2)])

    This formula will be applied to a spreadsheet with a lot of entries. I was planning on just copying the formula, but a looped IF statement may work better. I am not sure.

    Thanks in advance for the help.

    Arli

    Date_IF_Statement.xlsx

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Checking a cell for a value then adding months/years to a date in a second column

    Try

    =IF(A2="y",DATE(YEAR(B2),MONTH(B2)+75,DAY(B2)),DATE(YEAR(B2),MONTH(B2)+36,DAY(B2)))

  3. #3
    Registered User
    Join Date
    01-30-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: Checking a cell for a value then adding months/years to a date in a second column

    =IF(A2="y", DATE(YEAR(B2),MONTH(B2)+75,DAY(B2)),DATE(YEAR(B2),MONTH(B2)+36,DAY(B2)))

    Not really ninja-ed by above poster, but I certainly hadn't seen that reply when I posted, doh!

  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Checking a cell for a value then adding months/years to a date in a second column

    Alternate formula:
    =IF(OR(A2={"y","n"}),DATE(YEAR(B2),MONTH(B2)+IF(A2="y",75,36),DAY(B2)),"")
    Last edited by tigeravatar; 01-31-2012 at 04:11 PM.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  5. #5
    Registered User
    Join Date
    12-07-2009
    Location
    Washington, DC
    MS-Off Ver
    excel 2007
    Posts
    5

    Re: Checking a cell for a value then adding months/years to a date in a second column

    They both work great! Thanks for your time.

    Arli

+ 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