Auto Populating and Formatting Data
The two subs I posted work only on the active cell. You could combine into one
sub.
One button for one macro to enter the date and time in the active cell.
Sub NOWTIME()
ActiveCell.Value = Format(Now(), "dd-mm-yyy h:mm:ss AM/PM")
End Sub
But......................maybe better is event code.
To have the date and time automatically in column B when you enter a WAT# in
Column C
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo enditall
Application.EnableEvents = False
If Not Application.Intersect(Target, Columns("C:C")) Is Nothing Then
Target.Offset(0, -1).Value = Format(Now(), "dd-mm-yyyy h:mm:ss AM/PM")
End If
enditall:
Application.EnableEvents = True
End Sub
This is sheet event code. Right-click and "View Code".
Copy/paste the above into that sheet module.
When you enter a WAT# in column C the static date and time will appear in same
row in column B
Gord
On Wed, 3 Oct 2007 11:57:01 -0700, Clark
wrote:
Thanks for the prepend info! works like a charm.
I am interested in the below routine. My date coloum is coloum B. does the
below need to be modified to effect B alone? i need a stamp that has both
time and date.
--
Clark
"Gord Dibben" wrote:
Sub NOWDATE()
ActiveCell.Value = Format(Date, "dd-mmm-yy")
End Sub
Sub NOWTIME()
ActiveCell.Value = Format(Now(), "h:mm:ss AM/PM")
End Sub
If you wanted, you could set up event code that would stamp date or time or both
whenever you enter the WAT# without using a button or keyboard.
|