ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   date stamp (https://www.excelbanter.com/excel-programming/425064-date-stamp.html)

paula

date stamp
 
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!
--
paulao

Philosophaie

date stamp
 
Sheets("Sheet1").Range("A1") = Format(Now, "mmm dd yyyy hh:mm:ss AMPM")

"paula" wrote:

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!
--
paulao


Stewart Gordon

date stamp
 
Philosophaie wrote:
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.

Ritwik Shukla

date stamp
 
I am assuming that you are doing a row level entry, and lets 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


[email protected]

date stamp
 
On Mar 5, 4:22*am, Stewart Gordon wrote:
Philosophaie wrote:
*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.


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

Matt


All times are GMT +1. The time now is 05:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com