Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Automatically Timestamp Entries in Excel

0

Hi 

My workshit is not entering or showing any of the Automatic dates when i enter on the data range, what must i be missing? here is the code i used.

Private Sub Worksheet_Change(ByVal Target As Range)

'Timestamp Data

'   TeachExcel.com

Dim myTableRange As Range

Dim myDateTimeRange As Range

Dim myUpdatedRange As Range

'Your data table range

Set myTableRange = Range("A7:J62")

'Check if the changed cell is in the data tabe or not.

If Intersect(Target, myTableRange) Is Nothing Then Exit Sub

'Stop events from running

Application.EnableEvents = False

'Column for the date/time

Set myDateTimeRange = Range("K" & Target.Row)

'Column for last updated date/time

Set myUpdatedRange = Range("L" & Target.Row)

'Determine if the input date/time should change

If myDateTimeRange.Value = "" Then

    myDateTimeRange.Value = Now

End If

'Update the updated date/time value

myUpdatedRange.Value = Now

'Turn events back on

Application.EnableEvents = True

End Sub

Answer
Discuss

Discussion

Your code works for me. The definition for "work" is that when you make a change in any of the cells A7:J62 at least one time entry will be made in columns K:L of the row in which the change took place.
Variatus (rep: 4889) Jul 18, '20 at 8:16 pm
Add to Discussion



Answer the Question

You must create an account to use the forum. Create an Account or Login