title: Excel VBA Export Multiple sheets to PDF
body: <p>I have been trying to export a named range on multiple worksheets to a single pdf. Initially, it seemed to work fine, then I noticed the the selected range would change when loading the various sheets into an array.</p>
  
  <p>It is my understanding by using <code>Selection.ExportAsFixedFormat</code> this would export the selected cells only. Therefore, I have a macro to loop through the required sheets, select the various ranges need then create an array for all the sheets to allow exporting to a single pdf.</p>
  
  <pre><code>Dim wb As Workbook
  Dim srcSht As Worksheet
  Dim toPrnt As String
  
  Set wb = ThisWorkbook
  Set srcSht = wb.Sheets("print_array")
  
  Dim myArr1() As Variant
      myArr1 = srcSht.Range("myPrintArray")
  
  Dim i As Long
  Dim j As String
      For i = LBound(myArr1, 1) To UBound(myArr1, 1)
              j = myArr1(i, 1)
  
      wb.Sheets(j).Activate
          wb.ActiveSheet.Range("CCB_" &amp; Left(j, 5) &amp; "_Print").Select
  
      Next i
  
  wb.Sheets(Array("CAT01 - Request for Resource", _
                              "CAT02 - Resource Allocation", _
                              "CAT03 - Product Data Sources", _
                              "CAT04 - Target &amp; Control Cells", _
                              "CAT05 - Matching And Deduping", _
                              "CAT06 - Exclusions", _
                              "CAT07 - Data from other teams", _
                              "CAT08 - Outputs", _
                              "CAT09 - Special Instructions", _
                              "CAT10 - Brief Meeting Sign Off" _
                              )).Select
  
  Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename:=PDF_FileAndPath, _
  Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
      :=False, OpenAfterPublish:=True
  </code></pre>
  
  <p>When stepping through the code, everything goes to plan right up to creating the sheets array, at this point the selected ranges change.</p>
  
  <p>I have also tried using PageSetup, but the result is the same.</p>
  
  <pre><code>With ActiveSheet.PageSetup
      .Orientation = xlLandscape
      .PaperSize = xlPaperA4
      .Zoom = False
      .FitToPagesWide = 1
      .FitToPagesTall = 1
      .PrintArea = Range("CCB_" &amp; Left(j, 5) &amp; "_Print").Address
  End With
  </code></pre>
  
  <p>After reviewing a few similar post in this forum, I am still at a loss.</p>
  
  <p>Can anyone shed light on why the selected range changes when creating the array or, have any other suggestions that may help?</p>
  
  <p>Many thanks</p>