Program a Function Key

  • Thread starter Thread starter John Sheakley
  • Start date Start date
J

John Sheakley

How do I program a function key on my keyboard to enter the current time
into a cell?
In one key press of the function key, the current time should be entered in
"h:mm AM/PM" format.
 
I'm not sure about function keys, but if a shortcut keys will do, here's
how:
- select Tools-Macro-Record New Macro.
- when the dialog appears, enter the key you want to use in the shortcut key
textbox.
- click the button with the blue square to stop recording.
- press Alt + F11 to display VBA
- type these lines before "End Sub" (or cut & paste):
ActiveCell.FormulaR1C1 = "=NOW()"
ActiveCell.NumberFormat = "h:mm AM/PM"
- close VBA, and try pressing CTRL + (your chosen key)
This should do the trick.
HTH
Chris
 
John Sheakley said:
How do I program a function key on my keyboard to enter the current
time into a cell?
In one key press of the function key, the current time should be
entered in "h:mm AM/PM" format.

Not sure if you need to.

Shift-Ctrl-; (semi-colon) enters the current time (rounded back to the
nearest minute) into the active cell.

You would have to pre or post format though if the standard time
format does not suit in a particular situation.

HTH,

Alan.
 
John Sheakley said:
How do I program a function key on my keyboard to enter the current
time into a cell?
In one key press of the function key, the current time should be
entered in "h:mm AM/PM" format.

Not sure if you need to.

Shift-Ctrl-; (semi-colon) enters the current time (rounded back to the
nearest minute) into the active cell.

You would have to pre or post format though if the standard time
format does not suit in a particular situation.

HTH,

Alan.
 
Back
Top