I have written a VBA code which copies data from a pivottable into another worksheet in order to store this data. The data is monthly and counts the amount of devices, this is needed to create a historical database.
Sub DataTransferv1()
Dim lastrow As Long, erow As Long
'Stamp from when the data set is (in months) Worksheets("Database").Select
Worksheets("Database").Range("A3").Select
If Worksheets("Database").Range("A3").Offset(1, 1) <> "" Then
Worksheets("Database").Range("A3").End(xlDown).Select
ActiveCell.FormulaR1C1 = "=NOW()"
End If
'To check the last filled line on sheet 'Database_Input' lastrow = Sheet12.Cells(Rows.Count, 1).End(xlUp).Row
'Copy Paste section For i = 2 To lastrow
Sheet12.Cells(i, 1).Copy
erow = Sheet14.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Sheet12.Paste Destination:=Worksheets("Database").Cells(erow, 1)
Sheet12.Cells(i, 2).Copy
Sheet12.Paste Destination:=Worksheets("Database").Cells(erow, 2) Next i
End Sub
The problem with this code, it keeps paste a date stamp in the last used cell (So it overwrites the last row of copied data). How can I fix this as I don't see it anymore. Also, what VBA formula can be used for a static date stamp, in the regular excel its Shift + ; but I cant find the formula for this.
Thank you very much!