+ Reply to Thread
Results 1 to 3 of 3

Macro to search for patterns in a range of dates

  1. #1
    Registered User
    Join Date
    04-12-2008
    MS-Off Ver
    Office 365
    Posts
    44

    Macro to search for patterns in a range of dates

    Hey all,

    I'm not sure how easy this would be to put into a macro, but I was wondering if Excel can check a date and compare it to various criteria.

    The worksheet will have dates in a single column, one date per month. I would like a macro to check if the most recently entered date meets any of the following...

    1) Is the date (ie the 21st of the month) within five days of the previous month?
    2) Is the day (ie Tuesday) the same day as 3 or more of the previous six months?
    3) Is the date in the same half of the previous month (ie after the 15th both months)?
    4) Is there an alternating pattern of dates (ie 1st, 22nd, 1st, 22nd)?

    As an example assume the following data in A1:A6 - 1/12/11, 2/14/11, 3/21/11, 4/5/11, 5/12/11, 6/27/11

    Now, the user would enter 7/24/11 in A7 and the system would prompt that it is within 5 days of 6/27/11 (#1 above) and is in the same half of the month as June (#3 above).

    Once I get the skeleton of the macro down, I can incorporate (I think) any additional parameters that may arise, but I'm not sure how to check the data in the most recently entered cell for various criteria against the 6 months prior.

    I hope this is somewhat clear, but feel free to ask additional questions for clarity.

    Thanks so much for your help!

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Macro to search for patterns in a range of dates

    See if this workbook gives you some ideas.

    I don't know what you mean in part 1.

    Enter some dates in A10 down.

    Hope this is of some help.
    Attached Files Attached Files
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  3. #3
    Registered User
    Join Date
    04-12-2008
    MS-Off Ver
    Office 365
    Posts
    44

    Re: Macro to search for patterns in a range of dates

    Marcol,

    Thanks for the workbook. It's kind of what I'm looking for but would much rather have it in macro form so the cells can't inadvertently be changed. It will ultimately be a message box that pops up after a date has been entered with any patterns found.

+ 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