ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code help. (https://www.excelbanter.com/excel-programming/271858-code-help.html)

Ken[_8_]

Code help.
 
All,

Can anyone provide some code that will allow me to enter
the current time into the active cell? I know the shortcut
Ctrl+Shift+Colon will enter the time in the cell, but I
would like to create a time button in this workbook, and
link this macro to it so the user will just have to select
the cell and hit the button to enter the current time. Can
anyone help? Thanks in advance!

Richard Choate

Code help.
 
ActiveCell = Format(Now(), "h:mm AM/PM")

Richard Choate

"Ken" wrote in message
...
All,

Can anyone provide some code that will allow me to enter
the current time into the active cell? I know the shortcut
Ctrl+Shift+Colon will enter the time in the cell, but I
would like to create a time button in this workbook, and
link this macro to it so the user will just have to select
the cell and hit the button to enter the current time. Can
anyone help? Thanks in advance!



acw

Code help.
 
Ken

try
ActiveCell.Value = WorksheetFunction.Text(Now(), "h:mm
AM/PM")

You will have to nominate the cell to put it in - this is
just to give you an idea for syntax.

Tony
-----Original Message-----
All,

Can anyone provide some code that will allow me to enter
the current time into the active cell? I know the

shortcut
Ctrl+Shift+Colon will enter the time in the cell, but I
would like to create a time button in this workbook, and
link this macro to it so the user will just have to

select
the cell and hit the button to enter the current time.

Can
anyone help? Thanks in advance!
.



All times are GMT +1. The time now is 09:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com