When I press a control button I want a macro to run a routine and enter todays date (and time) in column AI at the end of each row that doesn't already have the date in it. I am using the =Now() formula with the following routine. The date is static once it is entered at the end of the row, because I copy and paste just the values.
Sub Date ()
'Copy the =Now()formula
Range("AI1").Select
Selection.Copy
'Select a column with data in it to find the last row
Range("G3").Select
Selection.End(xlDown).Select
'Move the active cell over 28 cells and up 1 to get to the bottom of column AI
Selection.Offset(-1, 28).Select
'Select the empty cells at the bottom of the column minus the header
Range(Selection, Selection.End(xlUp)).Select
Selection.Offset(1, 0).Select
'Paste the formula to the empty cells
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
It works but I know there is an easier way that isn't so cumbersome.
Thanks in advance
Sub Date ()
'Copy the =Now()formula
Range("AI1").Select
Selection.Copy
'Select a column with data in it to find the last row
Range("G3").Select
Selection.End(xlDown).Select
'Move the active cell over 28 cells and up 1 to get to the bottom of column AI
Selection.Offset(-1, 28).Select
'Select the empty cells at the bottom of the column minus the header
Range(Selection, Selection.End(xlUp)).Select
Selection.Offset(1, 0).Select
'Paste the formula to the empty cells
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
It works but I know there is an easier way that isn't so cumbersome.
Thanks in advance
Last edited: