+ Reply to Thread
Results 1 to 38 of 38

Contract Expiry Dates

  1. #1
    Registered User
    Join Date
    05-12-2015
    Location
    HayWard,Ca
    MS-Off Ver
    Excel 2007?
    Posts
    19

    Contract Expiry Dates

    Hello,

    In dire need of help!

    I work at a company whom has many contracts with other companies and individuals. Each contract contains the effective date and expiration date. Recently we have run into the problem of using someones service who has an expired contract. We have no way of knowing when the contract expires unless we look at a hard/soft copy. We need a way to be notified when the contract is expired and when it is within 30 days of expiration.

    So I created a tracker for these contracts and within it is, the vendor/party, effective date, and expiration. Now all i need was the reminder

    I did some searching and discovered the conditional formatting. Worked like a charm! Then I realized it wasn't suiting our needs.

    What we need:
    For the cell to be highlighted when the expiration is within thirty days of the date marked in the cell, NOT within thirty days of current date.
    AND For the cell to highlight when current date is the same date (or past current date) of the date marked in the cell.

    For Example in the picture I have attached(if it is attached), you see in B2 the effective Date is Nov. 18 2014. This contract expires Nov. 18 2015. What I need to happen is thirty days before Nov. 18 2015, the cell automatically highlights itself blue so when we see this tracker lets say on Oct. 31 2015, we can see we are within thirty days of expiration and we can notify the contracted company for renewal.

    Also take a look at B4. Effective date is Nov. 27 2007 the expiration date is Nov. 27 2010. The expiration Date has passed, I need that to automatically change to red after the current date is past the cell date.

    I would greatly appreciate if anyone can tell me if what i need done is possible and can walk me through it.
    Attached Images Attached Images

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Contract Expiry Dates

    Hi,

    I was thinking this might best be put in the worksheet_activate event? That way the macro runs whenever this worksheet is activated. Give me your opinion on that... we can also make it run whenever the workbook is opened.
    Additionally, do you want the code to highlight the cell blue/red even if there is a renewal and new expiration date (in the other columns)
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Registered User
    Join Date
    12-16-2014
    Location
    Amsterdam, Nederland
    MS-Off Ver
    Excel 2013
    Posts
    71

    Re: Contract Expiry Dates

    HI,

    See attached file

    Bas
    Attached Files Attached Files

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Contract Expiry Dates

    I assume bartelba worked with conditional formatting... Which is probably the best and simplest approach. I got a little too focused on the fact it was in the macros section of the forum and handled it that way, but as I mentioned, conditional formatting is probably ideal. However, for my approach, you would go to vba editor (alt-f11), double-click the sheet name that has your data, and paste this code, which would run whenever the worksheet is activated:
    Please Login or Register  to view this content.
    Last edited by Arkadi; 05-12-2015 at 03:55 PM. Reason: Fixed typo on bartelba's name

  5. #5
    Registered User
    Join Date
    05-12-2015
    Location
    HayWard,Ca
    MS-Off Ver
    Excel 2007?
    Posts
    19

    Re: Contract Expiry Dates

    Exactly what is the Worksheet activate Event? I am open to anything that will work the way I need it to.

    As for the renewal I had played with a code for that as well wasn't 100% sure if I wanted to use it.

  6. #6
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Contract Expiry Dates

    Ok well a worksheet activate event gets triggered whenever the worksheet that the code is in gets activated, such as opening the workbook, or when you switch from another sheet to the the one in question.

  7. #7
    Registered User
    Join Date
    05-12-2015
    Location
    HayWard,Ca
    MS-Off Ver
    Excel 2007?
    Posts
    19

    Re: Contract Expiry Dates

    Quote Originally Posted by Arkadi View Post
    Hi,

    I was thinking this might best be put in the worksheet_activate event? That way the macro runs whenever this worksheet is activated. Give me your opinion on that... we can also make it run whenever the workbook is opened.
    Additionally, do you want the code to highlight the cell blue/red even if there is a renewal and new expiration date (in the other columns)
    Exactly what is worksheet activate event?

    Seems like whenever the workbook is opened is more ideal for it to run.
    as for the code for renewal I was contemplating doing that havent decided yet.

  8. #8
    Registered User
    Join Date
    05-12-2015
    Location
    HayWard,Ca
    MS-Off Ver
    Excel 2007?
    Posts
    19

    Re: Contract Expiry Dates

    Quote Originally Posted by Arkadi View Post
    Ok well a worksheet activate event gets triggered whenever the worksheet that the code is in gets activated, such as opening the workbook, or when you switch from another sheet to the the one in question.
    Sounds great!! sorry for my multiple post having a slow day with the computer. Will that code do what i need done?

  9. #9
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Contract Expiry Dates

    If on opening is good enough then go to vba editor (alt-f11), double click "ThisWorkbook" on the left towards the top, and paste this code:

    Please Login or Register  to view this content.

  10. #10
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Contract Expiry Dates

    Both should work...I don't know if you leave your book open for days at a time, and thought of worksheet change... but workbook open ought to do it by the sounds of it... less demanding i suppose.

  11. #11
    Registered User
    Join Date
    05-12-2015
    Location
    HayWard,Ca
    MS-Off Ver
    Excel 2007?
    Posts
    19

    Re: Contract Expiry Dates

    Quote Originally Posted by Arkadi View Post
    If on opening is good enough then go to vba editor (alt-f11), double click "ThisWorkbook" on the left towards the top, and paste this code:

    Please Login or Register  to view this content.
    after i paste what do i do?

  12. #12
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Contract Expiry Dates

    Well... #1 change Set ws = worksheets("Sheet1") to reference the actual sheet name that has your data... I hope the dates are in column C as in your example?
    Then save the workbook. The macro runs each time you open it again.

    You can also test it without having to open simply by hitting the run button in the top menu... the little green arrow that looks like the play button on a stereo.

  13. #13
    Registered User
    Join Date
    05-12-2015
    Location
    HayWard,Ca
    MS-Off Ver
    Excel 2007?
    Posts
    19

    Re: Contract Expiry Dates

    Quote Originally Posted by Arkadi View Post
    Well... #1 change Set ws = worksheets("Sheet1") to reference the actual sheet name that has your data... I hope the dates are in column C as in your example?
    Then save the workbook. The macro runs each time you open it again.

    You can also test it without having to open simply by hitting the run button in the top menu... the little green arrow that looks like the play button on a stereo.
    yes the dates are in column C. I change worksheets or sheet 1 in the set=ws? example the sheet name is contract database

  14. #14
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Contract Expiry Dates

    so then
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    05-12-2015
    Location
    HayWard,Ca
    MS-Off Ver
    Excel 2007?
    Posts
    19

    Re: Contract Expiry Dates

    Quote Originally Posted by Arkadi View Post
    so then
    Please Login or Register  to view this content.
    After I save it, it should be formatted the way i need it correct?

  16. #16
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Contract Expiry Dates

    If you mean the colours in the cells should be there, no, the code runs when you open the workbook, so save, close, re-open your excel file, and then yes it should be done.

    I'll be slow answering for a bit, heading home, but will check in when I arrive to respond to questions if you have any... If you are satisfied, reputation is appreciated but not required, however, please do mark the thread as solved once you are happy with the results.
    Last edited by Arkadi; 05-12-2015 at 04:20 PM.

  17. #17
    Registered User
    Join Date
    05-12-2015
    Location
    HayWard,Ca
    MS-Off Ver
    Excel 2007?
    Posts
    19

    Re: Contract Expiry Dates

    this appeared after reopening it
    Attached Images Attached Images

  18. #18
    Registered User
    Join Date
    05-12-2015
    Location
    HayWard,Ca
    MS-Off Ver
    Excel 2007?
    Posts
    19

    Re: Contract Expiry Dates

    and this when i clicked Debug
    the line reads: If ws.Range("C" & i).Value - 30 < Date And ws.Range("C" & i).Value > Date Then 'if the date in the cell is greater than today, and the value in the cell - 30 days is less than today then...
    Attached Images Attached Images

  19. #19
    Registered User
    Join Date
    05-12-2015
    Location
    HayWard,Ca
    MS-Off Ver
    Excel 2007?
    Posts
    19

    Re: Contract Expiry Dates

    also it did not apply to all of column C

  20. #20
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Contract Expiry Dates

    Are there some blanks in column c between dates?

  21. #21
    Registered User
    Join Date
    05-12-2015
    Location
    HayWard,Ca
    MS-Off Ver
    Excel 2007?
    Posts
    19

    Re: Contract Expiry Dates

    yes there are. They are unknown dates

  22. #22
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Contract Expiry Dates

    Oops, I should have thought of that. Gimme a min to log in on PC, phone is no good for this

  23. #23
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Contract Expiry Dates

    Ok.... sorry about that... silly mistake on my part

    Please Login or Register  to view this content.

  24. #24
    Registered User
    Join Date
    05-12-2015
    Location
    HayWard,Ca
    MS-Off Ver
    Excel 2007?
    Posts
    19

    Re: Contract Expiry Dates

    no worries at all. Super appreciate your time.

    Now what should I do about the debugging issue?

  25. #25
    Registered User
    Join Date
    05-12-2015
    Location
    HayWard,Ca
    MS-Off Ver
    Excel 2007?
    Posts
    19

    Re: Contract Expiry Dates

    I think the new code fixed the debug issue

  26. #26
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Contract Expiry Dates

    WAIT... bad choice, fixes issue... unless you have a word in by mistake or a letter...

  27. #27
    Registered User
    Join Date
    05-12-2015
    Location
    HayWard,Ca
    MS-Off Ver
    Excel 2007?
    Posts
    19

    Re: Contract Expiry Dates

    what's the issue?

  28. #28
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Contract Expiry Dates

    This is more solid code:

    Please Login or Register  to view this content.
    Problem was if you ever put a word or letter in column c by mistake or to mark unknown or something, then you'd get an error. This new one takes care of blanks AND letters

  29. #29
    Registered User
    Join Date
    05-12-2015
    Location
    HayWard,Ca
    MS-Off Ver
    Excel 2007?
    Posts
    19

    Re: Contract Expiry Dates

    ok! looks like it works. I put in yesterday's date to test it out...it didnt change color. I'm assuming changes won't be made until I close it and reopen it?

  30. #30
    Registered User
    Join Date
    05-12-2015
    Location
    HayWard,Ca
    MS-Off Ver
    Excel 2007?
    Posts
    19

    Re: Contract Expiry Dates

    YOU ARE MY SAVIOR!!!!! lets keep in touch I have a feeling I'lll be making a few more of these. You were a great help i really appreciate your time.

  31. #31
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Contract Expiry Dates

    that's right about change only when you open it... however, we can add the same routine somewhere else if you want it to work whenever you enter a date... that's a worksheet change event...

  32. #32
    Registered User
    Join Date
    05-12-2015
    Location
    HayWard,Ca
    MS-Off Ver
    Excel 2007?
    Posts
    19

    Re: Contract Expiry Dates

    Hi again. Hoping you could help me out. Im working with the same document and we have decided to add worksheets to the workbook. I want all of the functions in the first worksheet to work for the rest of the worksheets. (I added 3extra) Do I need a new code for that?

  33. #33
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Contract Expiry Dates

    I'm cooking dinner but will get back to you, not hard, no worries.

  34. #34
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Contract Expiry Dates

    Sorry nwarren, got caught up in stuff last night, but give this new code a try:

    Please Login or Register  to view this content.

  35. #35
    Registered User
    Join Date
    05-12-2015
    Location
    HayWard,Ca
    MS-Off Ver
    Excel 2007?
    Posts
    19

    Re: Contract Expiry Dates

    No worries.

    I tried it and it didnt seem to work on the other sheets the original sheet still works

  36. #36
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Contract Expiry Dates

    So you replaced the code in "ThisWorkbook" from before with this, but only the original sheet changed? Can you provide the current workbook?

  37. #37
    Registered User
    Join Date
    05-12-2015
    Location
    HayWard,Ca
    MS-Off Ver
    Excel 2007?
    Posts
    19

    Re: Contract Expiry Dates

    my apologies I put the code only in a sheet not the whole workbook. It works now

  38. #38
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Contract Expiry Dates

    Oh, lol OK. Great, easy solution

+ 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] Allocating a given date to a date range bucket: futures contract expiry
    By labogola in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-26-2013, 08:50 AM
  2. Replies: 1
    Last Post: 11-29-2013, 05:03 AM
  3. [SOLVED] Alarm activated when contract expiry date is reached?
    By mole_man in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 05-02-2013, 11:07 PM
  4. email alert for contract expiry
    By shaileshgavanang in forum Excel General
    Replies: 0
    Last Post: 04-16-2013, 12:00 PM
  5. Workday Formula-Notice dates and Expiry dates
    By lamjoey in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 07-24-2011, 06:52 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