+ Reply to Thread
Results 1 to 7 of 7

Event Procedure if Date is within timeframe

  1. #1
    Forum Contributor
    Join Date
    05-12-2021
    Location
    USA
    MS-Off Ver
    Microsoft Office LTSC Professional Plus 2021
    Posts
    212

    Event Procedure if Date is within timeframe

    Hello, I have a tab that I use to record when employees are to be paid vacations. It is called Future Paid Vacations. It is one of many tabs in the workbook, but it is the only one we are really concerned with for this. I have a date listed starting in E3 and so on(The number of rows of data can change) and this date is when employees are to be paid for their vacations. What I am looking for is every time the workbook is opened for a MsgBox to appear if the week that the date listed in column E happens to fall within current week that basically reminds me to check the Future Paid Vacations tab for a Vacation payment. I've been learning VBA thru a course I am currently taking, and know a tiny bit about Event Procedures, but I've not really dealt with codes yet regarding dates, so I am not sure how the wording would go for if the date is within current week. Any help will be appreciated.

  2. #2
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: Event Procedure if Date is within timeframe

    Is this what you mean?

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    05-12-2021
    Location
    USA
    MS-Off Ver
    Microsoft Office LTSC Professional Plus 2021
    Posts
    212

    Re: Event Procedure if Date is within timeframe

    HI ByteMarks thanks for the response. I did change the name Sheet1 in the code to the appropriate tab "Future Paid Vacations" and I entered today's date in cell E4 to test(There's already an entry for someone in E3 but it's a date outside of this week.) I saved it and it works but it only seems to work if the future paid vacations tab was the last tab the file was saved to and closed and then when the workbook opens up to that tab. Like I mentioned before, I use many other tabs in the workbook and wouldn't always be saving on that tab and closing. When I saved it on a different tab, closed the workbook and then opened it, I wasn't getting any pop-up. The solution is close, it's just that little bit I'm wondering if it can be fixed.

  4. #4
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: Event Procedure if Date is within timeframe

    Sorry, try it like this.

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    05-12-2021
    Location
    USA
    MS-Off Ver
    Microsoft Office LTSC Professional Plus 2021
    Posts
    212

    Re: Event Procedure if Date is within timeframe

    Perfect! It is displaying the pop-up now no matter what tab I leave off with. I tweaked the code slightly as needed for how I wanted the text to read in the pop-up with date formatting and such. I liked what you did with adding the current week date range to the title of the message box. Your code gives Monday thru Sunday date range but I changed that 2 at the top of the code to 1 and that gave me a Sunday thru Saturday range for that. Got it perfect to how I need it and this will be a big help, so thank you very much for your help!

  6. #6
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: Event Procedure if Date is within timeframe

    That's great. You're welcome.

  7. #7
    Forum Contributor
    Join Date
    05-12-2021
    Location
    USA
    MS-Off Ver
    Microsoft Office LTSC Professional Plus 2021
    Posts
    212

    Re: Event Procedure if Date is within timeframe

    So actually I spoke too soon, I have another problem which seems to have been caused by implementing this Event Code. It broke one of my other macros. In my macro List, that macro was called UpdateRatesPositionsMailDrops and was assigned to an autoshape button

    The code in case it may have relevance is:
    Please Login or Register  to view this content.
    After I implemented your event code, I now can't run my macro and when I look for that macro in my list, where before it read UpdateRatesPositionsMailDrops, it now reads: 'Payroll Nexus.xlsm'!UpdateRatesPositionsMailDrops.UpdateRatesPositionsMailDrops

    I know that has to be the cause, but the problem is, I can't assign that "newly named" macro back to the button. Would there be a fix for the Event Code for this?

    Just in case since I mentioned that I did modify the event code somewhat to attain a little more customization, here is the altered event code:

    Please Login or Register  to view this content.

    EDIT: I fixed it. a made a new macro without that long name, deleted the Autoshape and made a new one. Somehow that seems to have fixed it. I have no idea whatsoever as to why, but I will take it.
    Last edited by PitchNinja; 04-28-2023 at 02:49 PM.

+ 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] If cell has date within certain timeframe, change color?
    By shivers in forum Excel General
    Replies: 8
    Last Post: 06-24-2016, 08:09 PM
  2. Help with Event Procedure
    By bbright1 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 04-30-2013, 12:09 AM
  3. VLOOKUP based on date in specific timeframe
    By 4134x4nd3r in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-18-2013, 05:10 PM
  4. [SOLVED] Counting instances beyond date timeframe
    By jimrat in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-27-2012, 12:55 PM
  5. event procedure
    By Matija in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 02-23-2011, 08:13 AM
  6. [SOLVED] Event Procedure
    By Paul Johnson in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-02-2005, 10:06 AM
  7. [SOLVED] Event Procedure again
    By Paul Johnson in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-02-2005, 10:06 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