Automatically entering time and date to an entry

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How would I go about getting Excel to automatically attach the current date
and time to every entry i make? I am trying to form a phone log, and instead
of manually typing in the time and date of every phone call I record, I
wanted to see if there was any way it could be filled in automatically.
 
You could use a worksheet_change event in the sheet module

target.offset(,1)=date
target.offset(,2)=time
 
Ashlee

Use event code in the worksheet.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'when entering data in a cell in Col A
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 1 Then
n = Target.Row
If Excel.Range("A" & n).Value <> "" Then
Excel.Range("B" & n).Value = Now
End If
End If
enditall:
Application.EnableEvents = True
End Sub

This is sheet event code. Right-click on the sheet tab and "View Code".

Copy/paste into that module.

As written, date/time into B whenever a value is entered in A(column 1)


Gord Dibben MS Excel MVP
 

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

Back
Top