How can I get the system date & time for different cell record

  • Thread starter Get System Date & Time
  • Start date
G

Get System Date & Time

I'm trying to use EXCEL to capture transactions. For each transaction record,
I need to get the notebook system date & time. I use the "Now()" function,
but each time I hit enter all the values in the column changes to the current
date & time values. Is there another function/fomulae?
 
B

Bob Phillips

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H:H" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
.Offset(0, 1).Value = Format(Now, "dd mmm yyy hh:mm:ss")
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
G

Get System Date & Time

Bob Phillips said:
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H:H" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
.Offset(0, 1).Value = Format(Now, "dd mmm yyy hh:mm:ss")
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Get System Date & Time"
Thanks Bob for your help but I did not get it to work. I must have done
something wrong.
 
D

Dave Peterson

Hit and hold the control key
hit the semi-colon key (;)
(you'll see the date entered into the formulabar)
let go of the control key

Hit the space bar

hit and hold the control key
hit the colon key :))
(you'll see the time added to the formulabar)
let go of the control key

Hit enter to finish.

When you're done, you should see something like:
01/08/2008 09:12:00 AM
in the formulabar

(I use USA date order. Yours may be different.)
 
G

Get System Date & Time

Dave Peterson said:
Hit and hold the control key
hit the semi-colon key (;)
(you'll see the date entered into the formulabar)
let go of the control key

Hit the space bar

hit and hold the control key
hit the colon key :))
(you'll see the time added to the formulabar)
let go of the control key

Hit enter to finish.

When you're done, you should see something like:
01/08/2008 09:12:00 AM
in the formulabar

(I use USA date order. Yours may be different.)
Hi Dave, Thanks I got it to work. Thanks to "gary's Student" as I now
realise what you meant.
 
B

Bob Phillips

Be aware though that it only shows hours and minutes, not the seconds.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
G

Get System Date & Time

Bob Phillips said:
Be aware though that it only shows hours and minutes, not the seconds.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

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