Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date and Time Stamp in Excel 1

Status
Not open for further replies.

RachieD

Technical User
May 14, 2004
20
0
0
EU
Hi

I used the following FAQ707-1657 to set up a date stamp in Excel when data is entered, this worked fine.

Does anyone know how I can record the time too? At present the date is correct but the time shows as 00:00.

I amended the above FAQ with the .NumberFormat below, but it made no difference:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Cell As Range
    For Each Cell In Target
        With Cell
            If .Column = Range("G:G").Column Then
                Cells(.Row, "F").Value = Int(Now)
                .NumberFormat = "MM/dd/yy hh:mm:ss"
                End If
                End With
                Next Cell
            
End Sub
I don't mind if the time is recorded in the same cell as the date or a different one, but I would like to be able to see both.

Thanks!!
RachieD
 
Hi RachieD,

Now gives you the Date and Time. In this code the time has been chopped off by use of the Int function. To keep the Time part, change
Code:
[purple]Cells(.Row, "F").Value = Int(Now)[/purple]
to
Code:
[blue]Cells(.Row, "F").Value = Now[/blue]

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Hi Bob,

I do try to give descriptive answers which usually means someone gets in before me with a shorter one - but not this time [lol]

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Thanks Tony - it worked!! I appreciate your help.

RachieD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top