how to insert today's date on a hotkey (or F-key)?

  • Thread starter Thread starter Shiperton Henethe
  • Start date Start date
S

Shiperton Henethe

Hi
Any idea for how to insert today's date on a hotkey (or F-key)?
in MS Excel2002
(Would be useful for ms Word too, me thinks)

Thanks


Ship

Shiperton Henethe
 
Hi Ship!

You could write a macro, like:

Sub TodaysDate()
ActiveCell.FormulaR1C1 = Now
Selection.NumberFormat = "dd/mm/yyyy;@"
End Sub

Then go to Tools\Macro\Macros, select the macro and click on the Options
button, here you can enter the shortcut you want to start the macro.


Best regards

Stefan Hägglund
Microsoft
 
Minor niggle: If the date format is to be explicitly set (using
..NumberFormat), using .FormulaR1C1 adds unnecessary overhead in checking
for date or time format in the cell and, if not found, setting the
cell's format to the system short date format.

Less minor niggle1: If multiple cells are selected this will format all
selected cells (Selection) while entering a date/time in only one
(ActiveCell).

Less minor niggle2: If only the date is desired, entering Date, which
enters only the integer index, is more appropriate than Now, which adds
the time as a fractional day.

My suggestion:

Public Sub TodaysDate()
With ActiveCell
.NumberFormat = "dd/mm/yyyy"
.Value = Date
End With
End Sub
 
Back
Top