how can i output the current date into a cell?
Special feature:
I use a column as a template, where the current date should be entered daily. If I copy the column, the current date should be transferred. However, the date of previously copied columns is not allowed to change!
Example: Column A is the template. I have just copied it to Column C with VBA, now today's date should be displayed!
Column D I have already copied several days ago, there should be the old date in it, as correctly displayed!
goal is a kind of timestamp that stores the current date at the time of the copy into the cell
current VBA:
Sub ColumnCopyInsertNEW()
Const ColumnsAddress As String = "D:E"
Const LastColumnRow As Long = 2
With Columns(ColumnsAddress)
.EntireColumn.Hidden = False
.Copy
Dim cCount As Long: cCount = .Columns.Count
.Cells(LastColumnRow, 1).End(xlToRight) _
.Offset(1 - LastColumnRow, 1).Insert xlShiftToRight
.EntireColumn.Hidden = False
End With
End Sub
CodePudding user response:
Date
will give you today's date value.
Simply format to your needs
Range("C3").Value = Format(Date, "dd.mm.yyyy")