New Member
May 19, 2021
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 Drive\Operations\Fuel Prices\iFuel"
ActiveWorkbook.SaveAs Filename:= _
"G:\My Drive\Operations\Fuel Prices\iFuel\ThisWorkbook.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
Trusted Members
Moderators
November 1, 2018
You seem to have merged two separate saveas codes into one hybrid monster. 🙂 Try just:
ActiveWorkbook.SaveAs Filename:= _
"G:\My Drive\Operations\Fuel Prices\iFuel\ifuel " & Format(Date, " ddmmyyyy ") & ".xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
Note that you need an xlsx extension, not xls, if you specify that file format.
Answers Post
1 Guest(s)