Time/Date Stamp Multiple Rows

D

DataGuy

I am using the following code:

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("B16:F74")) Is Nothing Then
Range("G16:G74") = Now
Application.EnableEvents = True
End If
End Sub

I get the same time and date in all the rows. How can I fix my code so that
it is row specific.
 
D

Dave Peterson

Maybe something like:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim myRow As Long

If Target.Cells.Count > 1 Then
Exit Sub 'one cell at a time
End If

If Application.Intersect(Target, Me.Range("B16:F74")) Is Nothing Then
'do nothing
Else
myRow = Target.Row
With Me.Cells(myRow, "G")
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
Application.EnableEvents = False
.Value = Now
Application.EnableEvents = True
End With
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top