Copy & Paste with a VBA TimeStamp

Marsman

Board Regular
Joined
May 13, 2013
Messages
62
Office Version
  1. 365
Platform
  1. Windows
Hello folks - The following VBA code works great... the issue I am having is when someone does a Copy and Paste in Column K, the Time Stamp that is set for Column E will not do anything unless the value is entered one at a time.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("K:K")) Is Nothing Then

On Error Resume Next
    If Target.Value = "" Then

      Target.Offset(0, -6) = ""
    Else

      Target.Offset(0, -6).Value = Format(Now, "mm/dd/yyyy hh:mm:ss")

    End If

  End If

End Sub

Can someone explain to me how I could the TimeStamps show in Column E when I paste in multiple lines under Column K


Thanks
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Try this version:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim rng As Range, r As Range
    
    Set rng = Intersect(Target, Range("K:K"))
    
    If rng Is Nothing Then Exit Sub
    
'   Loop through each row in range
    For Each r In rng
        Application.EnableEvents = False
        If r.Value = "" Then
            r.Offset(0, -6) = ""
        Else
            r.Offset(0, -6).Value = Format(Now, "mm/dd/yyyy hh:mm:ss")
        End If
        Application.EnableEvents = True
    Next r

End Sub
 
Upvote 0
That is a beautiful thing....

Thanks for the help. :)
 
Upvote 0

Forum statistics

Threads
1,215,363
Messages
6,124,505
Members
449,166
Latest member
hokjock

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