Greetings. May I please request some assistance with a macro?
I want to create a macro that will automatically enter the date and time in adjacent cells.
I know the command for Date, and the command for Time.
Date = CTRL + ;
Time = CTRL + SHIFT + ;
The problem I’m having is this: The macro that I recorded (see below) always enters the Date in cell H2. And it always enters the Time in cell I2.
I want the macro to enter the date and time starting with the cell I put the cursor in prior to running the macro.
For example, if I put the cursor in cell H89, then that’s where I want the date entered, and then the time in I89.
How do I record or write the macro to do this? Or is there an easier way to do this?
Thank you very much. J. Danniel
I want to create a macro that will automatically enter the date and time in adjacent cells.
I know the command for Date, and the command for Time.
Date = CTRL + ;
Time = CTRL + SHIFT + ;
The problem I’m having is this: The macro that I recorded (see below) always enters the Date in cell H2. And it always enters the Time in cell I2.
I want the macro to enter the date and time starting with the cell I put the cursor in prior to running the macro.
For example, if I put the cursor in cell H89, then that’s where I want the date entered, and then the time in I89.
How do I record or write the macro to do this? Or is there an easier way to do this?
Thank you very much. J. Danniel
Code:
Sub DateTime()
' DateTime Macro
' Keyboard Shortcut: Ctrl+d
Range("H2").Select
ActiveCell.FormulaR1C1 = "5/29/2023"
Range("I2").Select
ActiveCell.FormulaR1C1 = "7:56 PM"
Range("H2").Select
End Sub
Last edited by a moderator: