Print Multiple Excel sheets in a specific order

Kakeda

I am trying to print/publish multiple sheets from Excel workbook, but in a specific order. I use the same code used here but it is not printing in the order I inputted into my array and alternatively is printing from leftmost sheet to the rightmost sheet.

Save multiple sheets to .pdf

I would like to print the sheets in a specific order. I selected the order that I wanted to print, however, it printed from left most sheet and going to right in the way they were in the workbook. How can I make them print in the order that I inputted in the array.

I selected

ThisWorkbook.Sheets(Array("GIT 100", "GIT 399", "CheckList GIT 400", "TCCC", "4.1")).Select

But I got "4.1","CheckList GIT 400","GIT 399","TCCC","GIT 100" as the published document.

Any help would be much appreciated.

Gary's Student

Just loop:

Sub Kakeda()
    ary = Array("GIT 100", "GIT 399", "CheckList GIT 400", "TCCC", "4.1")
    For Each a In ary
        Sheets(a).ExportAsFixedFormat Type:=xlTypePDF
    Next a
End Sub

EDIT#1:

This version will save the .pdf files separately:

Option Explicit

Sub Kakeda()
    Dim ary
    Dim a As Variant, fp As String
    ary = Array("GIT 100", "GIT 399", "CheckList GIT 400", "TCCC", "4.1")
    fp = ActiveWorkbook.Path
    For Each a In ary
        Sheets(a).ExportAsFixedFormat Type:=xlTypePDF, Filename:=fp & "\" & a & ".pdf"
    Next a
End Sub

EDIT#2:

This version will create a single pdf

Option Explicit

Sub Kakeda3_TheSequel()
    Dim ary
    Dim a As Variant, fp As String
    ary = Array("GIT 100", "GIT 399", "CheckList GIT 400", "TCCC", "4.1")
    fp = ActiveWorkbook.Path

    For Each a In ary
        Sheets(a).Move after:=Sheets(Sheets.Count)
    Next a

    ThisWorkbook.Sheets(ary).Select
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF
End Sub

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Print Multiple Excel sheets in a specific order

From Dev

Excel macro to print sheets based on multiple values

From Dev

Select and print multiple sheets in one print job Excel VBA

From Dev

How to print multiple Excel sheets into a single PDF file?

From Dev

Pull data from multiple Excel sheets and count specific items

From Dev

refer to multiple excel sheets

From Dev

VLOOKUP and IF in multiple excel sheets

From Dev

excel countif multiple sheets

From Dev

Print a list in a specific order in Python

From Dev

Reading Excel file with multiple sheets

From Dev

Export to excel multiple sheets/tabs

From Dev

Exporting Data To Multiple Excel Sheets

From Dev

Excel Chart from Multiple Sheets

From Dev

Using VLOOKUP and multiple sheets in Excel

From Dev

Reading Excel file with multiple sheets

From Dev

Print all sheets in workbook except for 3 specific sheets

From Dev

Print all sheets in workbook except for 3 specific sheets

From Dev

VBA Excel, copied sheets come in wrong order

From Dev

Compare multiple columns in multiple sheets excel

From Dev

Export Multiple Datasets to Multiple Excel sheets in ssrs

From Java

Loop to create multiple sheets in multiple Excel workbooks

From Dev

Compare multiple columns in multiple sheets excel

From Dev

sort data in descending order in multiple sheets

From Dev

sort data in descending order in multiple sheets

From Dev

Searching for multiple substrings in random order in Google Sheets

From Dev

Copy specific columns from multiple sheets into one

From Dev

Copy specific columns from multiple sheets into one

From Dev

mysql order by multiple value in specific order

From Dev

Retrieving Mysql data and print in specific order

Related Related

HotTag

Archive