dcsimg
Results 1 to 8 of 8

Thread: [RESOLVED] [EXCEL] - Last Modification Date Not Updating

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2018
    Posts
    10

    Resolved [RESOLVED] [EXCEL] - Last Modification Date Not Updating

    Hey y'all, I'm using the following code to insert the last modified date in my spreadsheet, but it isn't updating. Am I missing something?

    Code:
    Private Sub Worksheet_Calculate()    
    On Error Resume Next    
    Application.EnableEvents = False    
    Range("A1") = "Last Modified: " & Format(Now, "mm/dd/yy hh:mmampm")    
    Application.EnableEvents = True
    End Sub
    
    Private Sub Worksheet_Change(ByVal Target As Range)   
    On Error Resume Next    
    Application.EnableEvents = False    
    Range("A1") = "Last Modified: " & Format(Now, "mm/dd/yy hh:mmampm")   
    Application.EnableEvents = True
    End Sub

    Thanks in advance!

  2. #2
    New Member Leith Ross's Avatar
    Join Date
    Feb 2018
    Posts
    9

    Re: [EXCEL] - Last Modification Date Not Updating

    Hello Digtheradness,

    What do you see in cell "A1"?

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,724

    Re: [EXCEL] - Last Modification Date Not Updating

    if you remove OERN, you will at least know if there is some error
    if you put a breakpoint in your code you will know if the procedure(s) is running at all
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,532

    Re: [EXCEL] - Last Modification Date Not Updating

    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Column <> 1 Or Target.Row <> 1 Then
            ActiveSheet.Range("A1").Value = "Last Modified: " & Format(Now, "mm/dd/yy hh:mmampm")
        End If
    End Sub

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2018
    Posts
    10

    Re: [EXCEL] - Last Modification Date Not Updating

    Quote Originally Posted by Leith Ross View Post
    Hello Digtheradness,

    What do you see in cell "A1"?
    Hello, Thanks for responding.

    I actually have the wrong cell in the code, but fixing that didn't fix the problem. It should be "A2" and I don't see anything in the cell.

    **Edit - When I select Worksheet_Change in the procedure drop down and click run, it will put "Last Modified: & current date and time".
    Last edited by Digtheradness; May 14th, 2018 at 06:27 AM.

  6. #6

    Thread Starter
    New Member
    Join Date
    May 2018
    Posts
    10

    Re: [EXCEL] - Last Modification Date Not Updating

    Quote Originally Posted by westconn1 View Post
    if you remove OERN, you will at least know if there is some error
    if you put a breakpoint in your code you will know if the procedure(s) is running at all

    Hey westconn1,

    I removed OERN and there are no errors, and tried breakpoints. It doesn't seem to be running at all.

    Does one of them, or something else, need to go in "ThisWorkbook" as opposed to the module? I'm still a little fuzzy on what the difference is to be honest.

    **Edit - I figured out that it needs to go in "Sheet1"

    Thanks again for your time!
    Last edited by Digtheradness; May 14th, 2018 at 11:47 AM.

  7. #7
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,724

    Re: [RESOLVED] [EXCEL] - Last Modification Date Not Updating

    I figured out that it needs to go in "Sheet1"
    hard for us to see that!!

    if you are using events always select the event from the dropdown lists, if they are not in the list, you are in the wrong module
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  8. #8

    Thread Starter
    New Member
    Join Date
    May 2018
    Posts
    10

    Re: [RESOLVED] [EXCEL] - Last Modification Date Not Updating

    Quote Originally Posted by westconn1 View Post
    hard for us to see that!!

    if you are using events always select the event from the dropdown lists, if they are not in the list, you are in the wrong module
    Thanks for that tip.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width