add time to a time stamp

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,259
Office Version
  1. 2010
Platform
  1. Windows
Hi i have used your code below, but i want to add time to the date in Row Q can you help me please?

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim Changed As Range, Rw As Range

  Set Changed = Intersect(Target, Union(Range("H:H"), Range("H:H")))
  If Not Changed Is Nothing Then
    Application.EnableEvents = False
    For Each Rw In Changed.Rows
      Cells(Rw.Row, "P").Value = Environ("Username")
      Cells(Rw.Row, "Q").Value = Now
    Next Rw
    Application.EnableEvents = True
  End If
End Sub
 
hi all, thanks for your help. I have used the code below, which works but for some reason the date is coming up as 0/01/1900, any ideas to why this is happening?
Code:
Cells(Rw.Row, "Q").Value = Cells(Rw.Row, "Q").Value + (Now - Date)
 
Upvote 0

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hi,

Test following :

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim Changed As Range, Rw As Range


  Set Changed = Intersect(Target, Union(Range("H:H"), Range("H:H")))
  If Not Changed Is Nothing Then
    Application.EnableEvents = False
    For Each Rw In Changed.Rows
      Cells(Rw.Row, "P").Value = Environ("Username")
      Cells(Rw.Row, "Q").Value = Now
      Cells(Rw.Row, "Q").NumberFormat = "dd/mm/yyyy hh:mm:ss"
    Next Rw
    Application.EnableEvents = True
  End If
End Sub

HTH
 
Upvote 0
hi that works great now many thanks for your help, it is greatly appreciated :)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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