Forum Discussion
Shylyn
Aug 16, 2021Copper Contributor
Time Macros
I am trying to create a time sheet kinda workbook. I am wanting to set it up that when you click a button it will enter the current time. I need multiple buttons to do this to enter breaks, lunch, et...
- Aug 16, 2021
Instead of setting the formula of a cell to "=NOW()", set its value to Now. For example:
Sub SetTime() Range("D2").Value = Now End Sub
.
mathetes
Aug 16, 2021Silver Contributor
Presumably you're entering the current time via the function NOW(). One possible resolution is to include in the macro the instructions to copy, and then use Paste Special ... Values and Number Formatting to replace the NOW() with the simple value, which won't be updated.
- ShylynAug 16, 2021Copper ContributorI am using the NOW() function. I am not copying it for the other buttons, I was adding it to each button individually. I tried the copy/paste and figured that was the issue. I will try the Paste special and see if that works. I know very little about macros and I am trying to replace a workbook for my job.
- HansVogelaarAug 16, 2021MVP
Instead of setting the formula of a cell to "=NOW()", set its value to Now. For example:
Sub SetTime() Range("D2").Value = Now End Sub
.
- ShylynAug 16, 2021Copper ContributorTHANK YOU SO MUCH! This is working just like I need it to.