+ Reply to Thread
Results 1 to 10 of 10

IF/AND statement to count date ranges?

  1. #1
    Registered User
    Join Date
    05-29-2017
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    4

    IF/AND statement to count date ranges?

    I'm admittedly an Excel amateur and am looking for some help to classify date ranges in the attached book.

    Columns E:G are meant to indicate whether or not the names in column A have volunteered over 1 months (30 days), 3 months (90 days), or 6 months (180 days).

    For example:

    James Brown's first/last dates are 4/1/17 & 5/31/17. 'yes' in 1 month (because over 30 days) but 'ignore' in 3months, 3 months columns because those dates are in the future and haven't occurred yet. This is important that it isn't classified as "no" because they are still actively volunteering in the future

    Jane Black's first/last is 5/1 and 5/10. She did not even meet 1 month, so all values for her are "no"

    Is there a way to automate the cells in E:G based on the time periods in the B, C, and D columns?
    Attached Files Attached Files

  2. #2
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: IF/AND statement to count date ranges?

    Hi xibkwt- welcome to Excel Forum. Questions:
    1) James Brown last = 5/31. Why future date?
    2) Jane Black first = 5/1, less than 30 days, why NO instead of IGNORE?
    3) from 2) how is Active status determined?


    Please click the Add Reputation star below any helpful posts, and if you have your answer, mark your thread as SOLVED (Thread Tools up top). Thanks!-Lee
    Last edited by leelnich; 05-29-2017 at 06:33 PM.

  3. #3
    Registered User
    Join Date
    05-29-2017
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    4

    Re: IF/AND statement to count date ranges?

    Quote Originally Posted by leelnich View Post
    Hi xibkwt- welcome to Excel Forum. Questions:
    1) James Brown last = 5/31. Why future date?
    2) Jane Black first = 5/1, less than 30 days, why NO instead of IGNORE?
    3) from 2) how is Active status determined?


    Please click the Add Reputation star below any helpful posts, and if you have your answer, mark your thread as SOLVED (Thread Tools up top). Thanks!-Lee
    Thanks for your reply, Lee.

    I realized I wrote the example book over a month ago so the dates are no longer relevant. I've updated it with newer examples (attached) along with better explanations for each.
    Attached Files Attached Files

  4. #4
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: IF/AND statement to count date ranges?

    try:
    E2: =IF(OR(D2="",E1=""),"",IF(IFERROR(AND(DATEDIF(TODAY(),$C2,"d")>7,DATEDIF($B2,$C2,"d")>E$1,E$1>=$G$1),0),"Ignore",IF($D2<E$1,"No",IF($D2>E$1,"Yes",""))))
    tested with your example only
    Attached Files Attached Files
    Last edited by sandy666; 05-29-2017 at 09:09 PM. Reason: file added

  5. #5
    Registered User
    Join Date
    05-29-2017
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    4

    Re: IF/AND statement to count date ranges?

    Quote Originally Posted by sandy666 View Post
    try:
    E2: =IF(E2="","",IF(IFERROR(AND(DATEDIF(TODAY(),$C2,"d")>7,DATEDIF($B2,$C2,"d")>E$1,E$1>=$G$1),0),"Ignore",IF($D2<E$1,"No",IF($D2>E$1,"Yes",""))))
    tested with your example only
    Hi sandy666,

    I converted the table to a range to try the formula but I'm getting a circular reference error

  6. #6
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: IF/AND statement to count date ranges?

    post edited, read again
    I forgot to say: three headers was changed to 30, 90, 180

    Note: Formula doesn't work with Excel Table

    with Ex.Tab
    you can try this one:
    =IF(OR(D2="",E1=""),"",IF(IFERROR(AND(DATEDIF(TODAY(),$C2,"d")>7,DATEDIF($B2,$C2,"d")>--E$1,--E$1>=--$G$1),0),"Ignore",IF($D2<--E$1,"No",IF($D2>--E$1,"Yes",""))))
    but headers should stay: 30, 90, 180
    Last edited by sandy666; 05-29-2017 at 09:46 PM.

  7. #7
    Registered User
    Join Date
    05-29-2017
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    4

    Re: IF/AND statement to count date ranges?

    Quote Originally Posted by sandy666 View Post
    post edited, read again
    I forgot to say: three headers was changed to 30, 90, 180

    Note: Formula doesn't work with Excel Table

    with Ex.Tab
    you can try this one:
    =IF(OR(D2="",E1=""),"",IF(IFERROR(AND(DATEDIF(TODAY(),$C2,"d")>7,DATEDIF($B2,$C2,"d")>--E$1,--E$1>=--$G$1),0),"Ignore",IF($D2<--E$1,"No",IF($D2>--E$1,"Yes",""))))
    but headers should stay: 30, 90, 180
    Thank you. I got it to work with the ranges perfectly

    I hate to be a bug...but is there any way to make it work with a Table? ie: replace the cell references with values (30/90/180) instead?
    Last edited by xibkwt; 05-29-2017 at 10:00 PM.

  8. #8
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: IF/AND statement to count date ranges?

    read post #6 again
    or check att.
    Attached Files Attached Files

  9. #9
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: IF/AND statement to count date ranges?

    you can try to play with REPLACE() for all three headers but it will go to be a monster

  10. #10
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: IF/AND statement to count date ranges?

    Also you can try with MID() but headers should be like: 1month (30), 3months (90), 6months (180) because my formula need number from headers.
    or with original headers try: =--CHOOSE(MATCH(E$1,{"1month","3months","6months"},0),30,90,180) but G1 should be REPLACEd to 180 and locked $G$1

    here is example for Ex.Tab. with your headers:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Thanks for feedback

    If problem is resolved mark thread SOLVED or maybe someone else will give you another solution
    Attached Files Attached Files
    Last edited by sandy666; 05-29-2017 at 10:30 PM. Reason: file added

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 11
    Last Post: 06-30-2016, 07:07 PM
  2. Help with IF statement formula using date ranges
    By blynch1023 in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 02-02-2015, 01:28 PM
  3. Nested What If statement using date ranges
    By Glenn1 in forum Excel General
    Replies: 3
    Last Post: 01-08-2012, 04:13 PM
  4. Nested What IF excel statement with date ranges
    By Glenn1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-08-2012, 01:47 PM
  5. Nested What If statement using date ranges
    By Glenn1 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-08-2012, 01:41 PM
  6. [SOLVED] count date ranges
    By murtaza in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  7. count date ranges
    By murtaza in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-18-2005, 12:05 PM

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