+ Reply to Thread
Results 1 to 6 of 6

Upon opening the WorkSheet, how to check the date

  1. #1
    Registered User
    Join Date
    08-25-2008
    Location
    Bahrain
    Posts
    25

    Upon opening the WorkSheet, how to check the date

    I have an excel worksheet which I use to update on weekly basis. A date should always be shown on the report and I should update it as of current. sometimes I forgot to change the date. I want the Worksheet every time I open it to check the date whether the date on the report is as of current. If not, I want the worksheet to alert me with msgbox asking me to change the date.

    Thanks for help...

  2. #2
    Registered User
    Join Date
    04-14-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    54

    Re: Upon opening the WorkSheet, how to check the date

    On the workbook open or worksheet activate event, you can add code to get current date and time (Now()). Then compare this with the date you have and if the later is older, then display a message box to prompt user to update the date.

  3. #3
    Registered User
    Join Date
    03-13-2008
    Posts
    52

    Re: Upon opening the WorkSheet, how to check the date

    Put the following formula into a cell near the cell containing the date you wish to check:

    Please Login or Register  to view this content.
    Format the cell with that formula so that the format of the date matches the format of the date of the cell containing the date you wish to check. You can also make it white so that this date isn't visible in future, it won't affect the macro.

    Put this code into the ThisWorkbook code part of VBA for your workbook:

    Please Login or Register  to view this content.
    Last edited by LiamPotter; 04-24-2009 at 09:23 AM.

  4. #4
    Registered User
    Join Date
    12-23-2007
    Posts
    47

    Re: Upon opening the WorkSheet, how to check the date

    Put a command in the THISWORKBOOK

    PHP Code: 
    Private Sub Workbook_Open()
            
    Range("’sheet1’!A1) = Date
    End Sub 

  5. #5
    Registered User
    Join Date
    03-13-2008
    Posts
    52

    Re: Upon opening the WorkSheet, how to check the date

    Quote Originally Posted by dgkindy View Post
    Put a command in the THISWORKBOOK

    PHP Code: 
    Private Sub Workbook_Open()
            
    Range("’sheet1’!A1) = Date
    End Sub 
    This guy is right - instead of checking when the workbook opens, just make the macro automatically update the date instead.

    I'd change the above though to this:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    08-25-2008
    Location
    Bahrain
    Posts
    25

    Re: Upon opening the WorkSheet, how to check the date

    Many thanks for all for their help
    Unfortunately none of the suggested codes works. The way I wantrf it is that once I open the workbook it should go directly to sheet1 and check the dates and should alert me via msgbox in that respect. Hope that someone helps me.

+ 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