Hello to all,
I of a novice with excel and VBA in particular.
But you help would be most appreciated where possible.
The issue I have is for my excel 2019, PC, sheet. I have several sheets within one workbook. I have attached the sheet i am have an issue with. I would like to save the attached sheet in the asssigned drive with the file name and current date, so that i do not copy over the provious file.
This is the VBA code (I have highlighted the issue text, which i have played around with) :
Range("A1:N130").Select
Selection.Copy
Sheets("Pricing ODOO").Select
Sheets("ODOO Out").Visible = True
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWindow.SmallScroll Down:=96
Sheets("ODOO Out").Select
Application.CutCopyMode = False
Sheets("ODOO Out").Copy
ChDir "G:My DriveOperationsFuel PricesiFuel"
ActiveWorkbook.SaveAs Filename:= _
"G:My DriveOperationsFuel PricesiFuelThisWorkbook.SaveAs, ": ifuel.xls " & Format(Date, " ddmmyyyy ") & ".xls"", FileFormat _
:=xlOpenXMLWorkbook, CreateBackup:=False
ActiveWindow.Close
Sheets("ODOO Out").Select
ActiveWindow.SelectedSheets.Visible = False
Sheets("Pricing ODOO").Select
Range("O4").Select
It all works perfectly well until i try to add the date element to the saving process.
Thanks
JK
You seem to have merged two separate saveas codes into one hybrid monster. 🙂 Try just:
ActiveWorkbook.SaveAs Filename:= _
"G:My DriveOperationsFuel PricesiFuelifuel " & Format(Date, " ddmmyyyy ") & ".xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
Note that you need an xlsx extension, not xls, if you specify that file format.
Thank you Velouria,
This appears to be working a treat.
BR
JK