+ Reply to Thread
Results 1 to 6 of 6

Return EDATE with an IF statement...? [SOLVED]

  1. #1
    Registered User
    Join Date
    01-21-2013
    Location
    Phoenix, AZ, USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Question Return EDATE with an IF statement...? [SOLVED]

    I searched the forums for EDATE but I didn't see anything that helped me, quite.

    This is the current formula:

    =IF(R2<20,"",IF(M2="Pre-QA",N2,IF(M2="Pending",N2,IF(U2=0,N2,O2))))

    Where N2 and O2 are both dates.

    I want the formula to change those to the end of the month for this cell but I can't figure out where to/how to put the EDATE bit in.

    Help? Thanks!
    Last edited by mirage1; 01-21-2013 at 02:17 PM. Reason: All resolved, thanks!

  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,939

    Re: Return EDATE with an IF statement...?

    Hi mirage1 and welcome to the forum

    Im not exactly sure what you are trying to achieve, but edate() calcs a date x mths before or after a given date?

    This is not what you want, but your formula could be simplified into...
    =IF(R2<20,"",IF(and(M2="Pre-QA",M2="Pending",U2=0),N2,O2))

    Perhaps if you uploaded a workbook, with a few samples of your expected outcome, we would be able to see what you wanted, and offer some suggestions?
    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.
    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 bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Return EDATE with an IF statement...?

    Just simplify your formula as per #2 and replace N2 with EDATE(N2,n) with n is number of months you wish to add(or substract). Same for O2.
    Quang PT

  4. #4
    Registered User
    Join Date
    01-21-2013
    Location
    Phoenix, AZ, USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Return EDATE with an IF statement...?

    I have never used an "and" statement, I need to learn! Also, maybe the thing I really wanted was EOMONTH?

    The formula is in column Q.

    The ultimate goal is to get the pivot chart to act properly. I want the data grouped by the month and year that is in column Q, but I can't group by month in the pivot table (I think because there are some fields that are blank?). So what I end up doing every week is using this formula to get the date, then going through column Q and manually changing them all so they actually show the first of the month (which day of the month doesn't matter, I just want them to group right in the pivot table). I realize that is completely silly!
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    01-21-2013
    Location
    Phoenix, AZ, USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Return EDATE with an IF statement...?

    The simplified formula changes the results, actually. When it's POST QA I need it to return either N, or O, depending on whether U=0 or not.

    And it seems EDATE isn't really what I needed! But, I tried replacing the N2 and O2 with EOMONTH(N2,0) and EOMONTH(O2,0) and that worked like a charm. Thank you!

    (Edited to add - I just realized that you couldn't tell from the original formula that there was a third possibility in column M. The simplified formula probably would have worked fine, without that.)
    Last edited by mirage1; 01-21-2013 at 02:18 PM.

  6. #6
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Return EDATE with an IF statement...?

    Using =EOMONTH(O2,0) returns the last day of the month of O2.
    =EDATE(EOMONTH(O2,0)+1,-1) returns the first day of the month of O2

+ 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