dannybland
New Member
- Joined
- Sep 12, 2014
- Messages
- 31
Hi,
I need to copy some data every month, paste it into a spreadsheet and then save it as a new file with updated date
The date is in the form mmyy but we will be opening last months file, deleting data from A6 down, and then pasting in new data, updating B3 and saving as this months date.
I can't get the date to work, please help
I need to copy some data every month, paste it into a spreadsheet and then save it as a new file with updated date
Code:
Sub InvoiceBackup()
Sheets("ASM001").Select
Range("A1048576").End(xlUp).Select
If ActiveCell.Row = 5 Then Exit Sub
Range( _
ActiveCell.End(xlUp).Offset(1, 14), _
ActiveCell.Offset(0, 0)).Select
Selection.Copy
'opening workbook
Workbooks.Open Filename:="H:\Finance\CBF\Invoices\Monthly Invoicing Summary\" & Year(Date) & "\ASM\" & (Now(mm) - 1) & Now(yy) & " ASM CBF Reg Summary.xlsx"
Range("A5").Select
Range( _
ActiveCell.End(xlDown).Offset(1, 14), _
ActiveCell.Offset(0, 0)).Select
Selection.Delete
Range("A6").Select
Selection.Paste
Range("B3").Select
ActiveCell.FormulaR1C1 = "TODAY()"
'below code for saving and closing the workbook
Workbooks("H:\Finance\CBF\Invoices\Monthly Invoicing Summary\" & Year(Date) & "\ASM\" & Now(mm) & Now(yy) & " ASM CBF Reg Summary.xlsx").Activate
ActiveWorkbook.Save
ActiveWorkbook.Close
End Sub
The date is in the form mmyy but we will be opening last months file, deleting data from A6 down, and then pasting in new data, updating B3 and saving as this months date.
I can't get the date to work, please help