How do I automatically enter a time and date?

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

Guest

I am trying to track calls that my sales staff makes on leads that I supply
them. Can anyone tell me how to set a column that automatically inserts a
date and time by just clicking on it? For example:
Name Of Borrower Lead Source Date and Time Called Result Notes
 
Either of two methods for automatic entry.

1. Double-click on a cell to enter time and date.

2. Enter data in one cell and date and time appear in another cell.

Manually...........Hold CTRL + ; then <space> then CTRL + SHIFT + ; then ENTER

Post back for event code for 1 or 2

2 is easist........no clicking.


Gord Dibben MS Excel MVP
 
Double-click is better. Say we use column C for this purpose. In worksheet
code, enter the following macro:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Set r = Range("C:C")
If Intersect(Target, r) Is Nothing Then Exit Sub
Target.Value = Now
Cancel = True
End Sub

REMEMBER: worksheet code, not a standard module
 
Thank you so much for responding...however, bear in mind that I am
"technologically challenged"! Can you send more detailed instructions on
where to find "worksheet code"? I can copy the macro, but do I start with
"Private" and end with "end sub"?
 
Because it is worksheet code, it is very easy to install and automatic to use:

1. right-click the tab name near the bottom of the Excel window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you have any concerns, first try it on a trial worksheet.

If you save the workbook, the macro will be saved with it.


To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm



You are also correct about the beginning and ending lines.
 
Back
Top