Timestamp (Code)

atomic2021

New Member
Joined
Dec 28, 2016
Messages
9
Hello all,

So, what I'm trying to do is have it so whenever any cell in column A-E is altered, column 'F' will display a timestamp. This might not be too complex, but I'm stuck. Here's what I have so far... I'm doing this in the "View Code" section if that makes a difference.

Sub Start_Process()
On Error GoTo Handler
If Target.Column = 1 Or 2 Or 3 Or 4 Or 5 And Target.Value <> "" Then
Application.EnableEvents = False
Target.Column = (6) = Format(Now(), "dd-mm-yyyy hh:mm:ss")
Application.EnableEvents = True
End If
Handler:
End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
The code needs to go in the module of the sheet you want this to happen on and you can access that by right clicking its tab and selecting View Code.

Once you've done that paste this code in.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cl As Range

    If Target.Column < 6 Then
        Application.EnableEvents = False
        For Each cl In Target.Cells
            Cells(Target.Row, "F").Value = Format(Now(), "dd-mm-yyyy hh:mm:ss")
        Next cl
        Application.EnableEvents = True
    End If
    
End Sub
Note that's pretty rough and ready code, might need a tweak or two, for example to check if there's already a value in F or check if the cell being changed is being cleared.
 
Upvote 0

Forum statistics

Threads
1,213,563
Messages
6,114,332
Members
448,566
Latest member
Nickdozaj

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