+ Reply to Thread
Results 1 to 20 of 20

Formula to return text when column has dates in a specific range

  1. #1
    Forum Contributor
    Join Date
    08-14-2016
    Location
    Warrington, England
    MS-Off Ver
    MS 365
    Posts
    168

    Formula to return text when column has dates in a specific range

    Hi everyone,

    I am trying to put together a formula to monitor frequencies of events at work, for example I want the cell to return "No" or "Yes" when certain triggers are met, in this instance I want it to return "Yes" when a column contains dates that all fall within a 3 month period.

    For example in the attached workbook there are a series of dates in column B, the only time the dates are within 3 months of each other is the last 3 entries, 23/10/2016, 11/11/2016 and 10/12/2016. There are 3 dates within 3 months, without the last entry the triggers met in C3 should read column B and return "No" as there have not been 3 dates which are in a 3 month period, once the most recent entry is added it should then return "Yes".

    Is this possible?

    Thanks in advance!
    Attached Files Attached Files
    Last edited by Catsonheat; 11-13-2016 at 08:18 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    05-08-2015
    Location
    Uvalde, TX
    MS-Off Ver
    2010
    Posts
    720

    Re: Formula to return text when column has dates in a specific range

    Hi,

    I think you are going to need a helper column that uses a formula to compare the adjacent "Date" cell to all the other dates in the column. Then your "Trigger" formula would look at the helper column to determine if there is a value equal to or grater than 3.

    In helper column I, cell I3, enter and copy down:
    Please Login or Register  to view this content.
    In "Trigger" cell use:

    Please Login or Register  to view this content.
    Hope this works for you and is helpful.

    Cheers

  3. #3
    Forum Contributor
    Join Date
    08-14-2016
    Location
    Warrington, England
    MS-Off Ver
    MS 365
    Posts
    168

    Re: Formula to return text when column has dates in a specific range

    Hi thanks for your response!

    It's the first time I have tried to use a formula like this so I am not sure if I have done it correctly as it doesn't seem to be working, I have attached the file below, can you let me know if I have missed something?

    Thanks!
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor
    Join Date
    05-08-2015
    Location
    Uvalde, TX
    MS-Off Ver
    2010
    Posts
    720

    Re: Formula to return text when column has dates in a specific range

    Hi,

    Almost there. Formulas in your helper column shouldn't look at anything other than the array that is being evaluated. Yours was also looking at the Trigger cell.

    See attached example.

    Cheers
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    08-14-2016
    Location
    Warrington, England
    MS-Off Ver
    MS 365
    Posts
    168

    Re: Formula to return text when column has dates in a specific range

    Hi Southward,

    Ah ok thanks! That makes sense it still seems to be slightly wrong in when it determines the triggers, it might be my poor explanation so apologies! When I input the first 2 dates no matter what I put the third date in it always returns "Yes" regardless of what date it is when it should only return yes if all 3 dates are within a 3 month period. for example if the first date is the 01/06/2016 the latest the third date can be for the trigger to be yes must be 01/09/2016, the second date can fall anywhere in between these dates really as then all 3 dates are within a 3 month period.

    Another example would be if the first date is 01/06/2016, the second date is the 01/09/2016, the third date is 01/10/2016 and then a fourth date is the 01/11/2016, the trigger should ignore the first date as the only three dates now within a 3 month period is the final three entries, so the trigger should read No until that last entry is put in place.

    If that makes sense haha, I think I have managed to confuse myself!

    Kind Regards,

    James

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,261

    Re: Formula to return text when column has dates in a specific range

    Try

    In I4 and copy down

    =IF(H4="",0,COUNTIF($H$4:H4,">="&H4-90))

  7. #7
    Valued Forum Contributor
    Join Date
    05-08-2015
    Location
    Uvalde, TX
    MS-Off Ver
    2010
    Posts
    720

    Re: Formula to return text when column has dates in a specific range

    Hi James,

    Sorry about that. I should have included an IF statement so the helper formula returned "nothing" if the adjacent cell was blank.

    Use this in I4 and copy down:

    Please Login or Register  to view this content.
    Cheers

  8. #8
    Valued Forum Contributor
    Join Date
    05-08-2015
    Location
    Uvalde, TX
    MS-Off Ver
    2010
    Posts
    720

    Re: Formula to return text when column has dates in a specific range

    Well there you have it with confirmation from John. And he is from your side of the world, so you know it has to be right.

  9. #9
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,261

    Re: Formula to return text when column has dates in a specific range

    Use Sothward's ....

    =IF(H4="","",COUNTIF($H$4:H4,">="&H4-90))

    to avoid 0 in your column

  10. #10
    Forum Contributor
    Join Date
    08-14-2016
    Location
    Warrington, England
    MS-Off Ver
    MS 365
    Posts
    168

    Re: Formula to return text when column has dates in a specific range

    Awesome guys thank you both so much! One final thing (hopefully!) and this is just a formatting issue but I can't seem to get it right, I am inputting these dates as we would do in the uk, so in the attachment I have put 01/01/16 and it detects this as the 1st of January, the second date I input is the 12th of January 12/01/16, however excel changes this automatically to the American date format meaning the first of December, so when I attempt to put in the twentieth of January 20/01/16 the formula no longer works as it is looking for a twentieth month! I have tried messing around with the formatting of the cells but it either doesn't work or if you delete the contents of the cell the format reverts back and so the formula stops working. Any suggestions?

    If this final tweek can be made I promise it's the last thing haha!

    Kind Regards
    Attached Files Attached Files

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,267

    Re: Formula to return text when column has dates in a specific range

    I'm not seeing this issue with your file. I can enter dates as dd/mm/yy without anything changing.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  12. #12
    Forum Contributor
    Join Date
    08-14-2016
    Location
    Warrington, England
    MS-Off Ver
    MS 365
    Posts
    168

    Re: Formula to return text when column has dates in a specific range

    Hmm that's strange, could this be an option/setting that is in Excel itself as opposed to a formatting issue? The file on my end is stuck as 01 January 2016, 01 December 2016 and 20/01/16 when trying to enter 01/01/16, 12/01/16 and 20/01/16

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,267

    Re: Formula to return text when column has dates in a specific range

    I don't know, but it's not the file:

    Excel 2016 (Windows) 32 bit
    H
    I
    2
    Trigger
    Helper
    3
    Yes
    4
    01 January 2016
    1
    5
    01 December 2016
    1
    6
    20 January 2017
    2
    7
    12 January 2016
    4
    8
    11 November 2016
    3
    9
    31 December 2016
    4
    10
    0
    11
    0
    12
    0
    13
    0
    14
    0
    15
    0
    16
    0
    Sheet: Sheet1

  14. #14
    Forum Contributor
    Join Date
    08-14-2016
    Location
    Warrington, England
    MS-Off Ver
    MS 365
    Posts
    168

    Re: Formula to return text when column has dates in a specific range

    It must be something my excel is doing, I have tried editing the format, text to columns, everything I can think of or find but it won't format on mine the way it should be as it showing on yours. I am so confused.

    UPDATE: Text to columns seems to be the issue? If put in 20/01/16 the formula does not work as it is searching for the format MDY and so it doesn't make sense, If i change this to DMY in text to columns it then updates and the formula works just fine however this only works after I have put a value in a cell, which means any time I want to put something into a cell or delete a call I have to go back into Text to Columns every time and change it, surely there is an easier way to do this?
    Last edited by Catsonheat; 11-13-2016 at 11:31 AM.

  15. #15
    Valued Forum Contributor
    Join Date
    05-08-2015
    Location
    Uvalde, TX
    MS-Off Ver
    2010
    Posts
    720

    Re: Formula to return text when column has dates in a specific range

    It may be due to me playing with custom formatting when I was working with it. I used custom format to force DD/MM/YYYY. Maybe if you remove the custom format it will revert back to your normal format.

    Sorry about that

  16. #16
    Forum Contributor
    Join Date
    08-14-2016
    Location
    Warrington, England
    MS-Off Ver
    MS 365
    Posts
    168

    Re: Formula to return text when column has dates in a specific range

    Doh! I worked it out, it's because I updated to Windows 10 yesterday and my computer defaulted its clock to US format so Excel was reading the format from my system no matter what I changed, I only just noticed it now! What an idiot haha! It's all fully working now thanks everyone! I will definitely be adding reputation for all your help!

    Thanks all!

  17. #17
    Valued Forum Contributor
    Join Date
    05-08-2015
    Location
    Uvalde, TX
    MS-Off Ver
    2010
    Posts
    720

    Re: Formula to return text when column has dates in a specific range

    Glad I could be of some assistance.

    Cheers

  18. #18
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,261

    Re: Formula to return text when column has dates in a specific range

    Thank you for the rep.

    As an aside, installed Windows 10 on 2 m/cs but didn't experience your problem!

  19. #19
    Forum Contributor
    Join Date
    08-14-2016
    Location
    Warrington, England
    MS-Off Ver
    MS 365
    Posts
    168

    Re: Formula to return text when column has dates in a specific range

    Hmmm how strange, at least it's all sorted now!

    One more question I wanted to add around adding functionality and understanding the formula. At the moment the formula looks for 3 dates that fall in a 3 month period, if I wanted to change this formula to look for 5 dates in a 5 month period I have managed to break the formula down from what you have provided so I can edit and tailor it and I have worked out how to get this functioning correctly by changing:

    =IF(MAX(C4:C9)>=3,"Yes","No") to: =IF(MAX(C4:C9)>=5,"Yes","No")

    and

    =IF(B5="",0,COUNTIF($B$5:B5,">="&B5-90)) to: =IF(B5="",0,COUNTIF($B$5:B5,">="&B5-150))

    Is there a way I could incorporate both of these? So the formula will look for 3 dates in a 3 month period and 5 in a 5 month period?

    Thanks again in advance!

  20. #20
    Valued Forum Contributor
    Join Date
    05-08-2015
    Location
    Uvalde, TX
    MS-Off Ver
    2010
    Posts
    720

    Re: Formula to return text when column has dates in a specific range

    That sounds like it could get very complicated.

    See attached example for a possible solution.

    Cell K3 is used to provide the number of dates per period.

    Keep in mind that the range of dates is on a 30 day basis.

    Cheers
    Attached Files Attached Files

+ 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. [SOLVED] Need formula to return a specific value if a specified date is between two other dates
    By BeachRock in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-04-2014, 02:03 PM
  2. [SOLVED] Formula to find a specific text within a range and return the value in the next cell
    By 00pumpkin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-19-2013, 02:11 PM
  3. Return value if value is bigger than 0, from specific range of dates,how?
    By ser_man in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-27-2013, 08:22 AM
  4. [SOLVED] Return specific text if a different text is contained anywhere in a range of cells
    By ciayers in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-06-2013, 05:54 PM
  5. Replies: 7
    Last Post: 09-18-2012, 04:17 PM
  6. [SOLVED] Find Specific Text in Text String and Return Value in Adjacent Column
    By watchouse in forum Excel General
    Replies: 2
    Last Post: 07-11-2012, 03:53 PM
  7. Replies: 3
    Last Post: 06-20-2012, 07:16 AM

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