VBA - Timestamp is not updating automatically after 1 day

Dream World

New Member
Joined
Jan 29, 2012
Messages
22
Hi there,

i have this file where i use it for my To Do list in my work. and after i set the code in the file it worked like a charm, after some time (usually 1 or 2 days) the code broke and when i fill a new item on my To Do list timestamp is not appearing or updating automatically anymore.

You can find the table below ..

ITEMTime & Date (Started)StatusWhoLast UpdateTime & Date (Last Update)Next ActionFollow upAction NeededEmail SubjectNo. of Days passed from last updateDuration

<tbody>
</tbody>


There are two timestamp in the code :
- (Time & Date (Started)): it will be updating only once when the ITEM is first created.
- (Time & Date (Last Update)): it will be updated every time there is a change in (Last Update) column.


VBA Code:

Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)    Dim rCell As Range
    Dim rChange As Range
    
    On Error GoTo ErrHandler
    Set rChange = Intersect(Target, Range("A:A"))
    If Not rChange Is Nothing Then
        Application.EnableEvents = False
        For Each rCell In rChange
            If rCell > "" Then
                With rCell.Offset(0, 1)
                    .Value = Now
                    .NumberFormat = "dd/mm/yyyy hh:mm:ss"
                End With
            Else
                rCell.Offset(0, 1).Clear
            End If
        Next
    End If


    Set WorkRng = Intersect(Application.ActiveSheet.Range("E:E"), Target)
    xOffsetColumn = 1
    If Not WorkRng Is Nothing Then
        Application.EnableEvents = False
        For Each Rng In WorkRng
            If Not VBA.IsEmpty(Rng.Value) Then
                Rng.Offset(0, xOffsetColumn).Value = Now
                Rng.Offset(0, xOffsetColumn).NumberFormat = "dd-mm-yyyy, hh:mm:ss"
            Else
                Rng.Offset(0, xOffsetColumn).ClearContents
            End If
        Next
        Application.EnableEvents = True
    End If
    
ExitHandler:
    Set rCell = Nothing
    Set rChange = Nothing
    Application.EnableEvents = True
    Exit Sub
ErrHandler:
    MsgBox Err.Description
    Resume ExitHandler
End Sub
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Have you restarted Excel? This is usually caused by some code disabling events and not re-enabling them.
 
Upvote 0
Yes tried restarting file, Excel. but no matter what i do it won't work anymore.
And this happened a couple of times, and each time i try to create the file from scratch in order for the code to work then this happen.
 
Upvote 0
If you open the VB Editor then go to the Immediate Window (Ctrl+G), and type:

Code:
?Application.enableevents

and press enter, does it return True or False?
 
Upvote 0
Returns nothing, only a message appeared saying "The Macros in this project are disabled". just found out when i checked (File > Options > Trust Center > Trust Center settings > Macro settings) that all macros option are disabled and cannot be modified.

Thanks for your help .. i appreciate it
 
Upvote 0
I guess that explains it then! ;)
 
Upvote 0

Forum statistics

Threads
1,215,497
Messages
6,125,158
Members
449,208
Latest member
emmac

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top