VBA save excel to pdf

MikeWall

New Member
Joined
Sep 26, 2016
Messages
16
Office Version
  1. 2016
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
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi again,

I also noticed that the print area for cover page is quite different to page 1 & page 2. In all the other sheets that we have this macro. they are all the same/format.

I'm very lost :confused:
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top