Time Stamp

  • Thread starter Thread starter mymk
  • Start date Start date
M

mymk

Is there a way to date and time an entry without using the "NOW" an
"TODAY" function (as it gets updated everytime the worksheet i
opened)?

For instance, how is it done so that everytime a letter is entered in
column, the column next to it will populate the date/time the letter i
entered in the spread sheet?

Is this do-able?

Thanks for any info
 
Hi

You can do it with the change event of the worksheet
This example will place the date/time in the B column if you change
a cell in the range A1:A20.

Place the code in the Sheet module

Right click on a sheet tab and choose view code
Paste the code there
Alt-Q to go back to Excel


Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("a1:a20"), Target) Is Nothing Then
Target.Offset(0, 1).Value = Format(Now, "mm-dd-yy hh:mm:ss")
End If
End Sub


For one column (1 = A) you can use
If Target.Column = 1 Then
 
Thank you gentlemen for the information.

Following up on the worksheet event macro, how does the code change i
there are multiple number of columns to be tracked and time stamped?
How does that change the code?

Thanks again for any info
 
Good point. The examples your were supplied with are probably
much to specific for normal use or continued use.

Normally instead of choosing a specific range, you would check
target.row and target.column to see if you want the timestamp
to occur. .

If the cell already has content you may not want to place a newer timestamp
into it -- for example the entry date for your bank balance.

Keep in mind that the worksheet change macro applies ONLY to the
worksheet it is installed with, so do not hesitate to modify it exactly
to what you want -- it's not going to be generic to your other usages
of worksheet change macros on other worksheets.

Avoid use of individual cell formatting within the worksheet change
macro as it will result in larger workbook sizes, you should be formatting
the entire column if you want a specific format.

Event Macros, Worksheet Events and Workbook Events
DateTimeStamp in Column A, on first entry in any other column on row
http://www.mvps.org/dmcritchie/excel/event.htm#datetimestamp
 
Back
Top