I am trying to add today's date to column A in sheet2. Each time my macro pastes my selection in sheet1, column B, to a new row in sheet2.
My script works to add the new row and paste my selection in sheet2, but I can't figure out how I should get the date in column A for the new row in sheet2. Here is the script in my macro;
Sub move()
Dim i As Integer
Application.ScreenUpdating = False
ActiveWorkbook.Sheets("Sheet1").Range("A1,A2,A3,A4,A5").Copy
Sheets("Sheet2").Select
i = 3
While Range("B" & i).Value <> ""
i = i + 1
Wend
Range("B" & i).Select
Selection.PasteSpecial (xlValues), Transpose:=True
Worksheets("Sheet1").Range("A1:A5").Clear
End Sub
Value = Format(Now(),"MM/DD/YYYY") . Modify as needed.
To insert today's date in Excel you simply type “=today” in the cell and then open and close brackets “()” with nothing in between them.
This example uses the Now function to return the current system date and time. Dim Today Today = Now ' Assign current system date and time.
The Microsoft Excel NOW function returns the current system date and time. The NOW function is a built-in function in Excel that is categorized as a Date/Time Function. It can be used as a worksheet function (WS) and a VBA function (VBA) in Excel.
Try the Date
function. It will give you today's date in a MM/DD/YYYY format. If you're looking for today's date in the MM-DD-YYYY format try Date$
. Now()
also includes the current time (which you might not need). It all depends on what you need. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With