Hi Guys,
New user here. I'm new to excel/vba and I just moved to a new position that requires high proficiency to Excel/vba. I am trying to save a couple of sheets in Excel to pdf.
Whilst the sheet saves, its saves in the wrong order e.g 1st page, 2nd page and cover page rather than cover page, page1 and page 2.
Can you guys help please. Here is the code
Sub Save_XLSX_to_folderV1_updated()
Worksheets("Control_Tab").Activate
'Define the file and folder names
folderlocation = Range("folder").Value
XLSXfilename = Range("file1").Value
PDFfilename = Range("file2").Value
' define the masterfile and the daily new file
Set Masterbook = ThisWorkbook
Workbooks.Add
Set DailyBook = ActiveWorkbook
' copy the relevant tabs from the masterfile to the daily file
Masterbook.Activate
Sheets(Array("Coverpage", "Page 2", "Page 3")).Select
'Sheets("Coverpage").Activate
Sheets(Array("Page 2", "Coverpage", "Page 3")). _
Copy Before:=DailyBook.Sheets("Sheet1")
'delete the blank sheet 1, 2, 3
Application.DisplayAlerts = False
Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
Sheets("Sheet3").Activate
ActiveWindow.SelectedSheets.Delete
Application.DisplayAlerts = True
I didn't right this code, I edited another code from an existing sheet.
Cheers,
Mike
New user here. I'm new to excel/vba and I just moved to a new position that requires high proficiency to Excel/vba. I am trying to save a couple of sheets in Excel to pdf.
Whilst the sheet saves, its saves in the wrong order e.g 1st page, 2nd page and cover page rather than cover page, page1 and page 2.
Can you guys help please. Here is the code
Sub Save_XLSX_to_folderV1_updated()
Worksheets("Control_Tab").Activate
'Define the file and folder names
folderlocation = Range("folder").Value
XLSXfilename = Range("file1").Value
PDFfilename = Range("file2").Value
' define the masterfile and the daily new file
Set Masterbook = ThisWorkbook
Workbooks.Add
Set DailyBook = ActiveWorkbook
' copy the relevant tabs from the masterfile to the daily file
Masterbook.Activate
Sheets(Array("Coverpage", "Page 2", "Page 3")).Select
'Sheets("Coverpage").Activate
Sheets(Array("Page 2", "Coverpage", "Page 3")). _
Copy Before:=DailyBook.Sheets("Sheet1")
'delete the blank sheet 1, 2, 3
Application.DisplayAlerts = False
Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
Sheets("Sheet3").Activate
ActiveWindow.SelectedSheets.Delete
Application.DisplayAlerts = True
I didn't right this code, I edited another code from an existing sheet.
Cheers,
Mike