date stamp

P

paula

I have a macro that is entering data and we want to make sure the data cannot
be backdated, so we want to add a time/date stamp in a cell to the right of
the entry as soon as it is made. I know I can use the "Now" function in the
spreadsheet, but how do I do it "behind the scenes"?

Thanks!
 
S

Stewart Gordon

Philosophaie said:
Sheets("Sheet1").Range("A1") = Format(Now, "mmm dd yyyy hh:mm:ss AMPM")
<snip top of upside-down reply>

Why not simply

Sheets("Sheet1").Range("A1") = Now

?

Stewart.
 
R

Ritwik Shukla

I am assuming that you are doing a row level entry, and let’s say your last
data entry column is F (6th Column) and you need the time stamp in column G.

Paste the code behind the worksheet

--------------
Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
On Error Resume Next

If Target.Column = 6 Then

ActiveCell.Offset(0, 1).Value = Now()
End If


End Sub
 
M

meh2030

<snip top of upside-down reply>

Why not simply

   Sheets("Sheet1").Range("A1") = Now

?

Stewart.

"Sheets("Sheet1").Range("A1") = Now" should work fine. It should also
give it a custom default format of "m/d/yyyy h:mm".

Matt
 

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