title: Export multiple ranges to a single PDF using VBA
body: <p>I'm trying to write a macro to cycle through a dropdown menu. Everytime the value in the drop down changes it will change the values on the worksheet. I won't to capture a range of the worksheet for every value in the dropdown in a VBA array and then export all of these ranges to single PDF. I'm able to export them one at a time to multiple PDFs but this isn't the objective. The problem I seem to be having is storing the different ranges in an Array. </p>
  
  <p>My code is as follows:</p>
  
  <pre><code>Sub bill_exporter()
  ' Macro to export billing estimates to a single pdf
  
  'Define Filenames and ranges
  Dim myfile As String
  Dim billsheet As Worksheet
  Dim print_area As Excel.Range
  Dim site As Range
  Dim arr() As Variant
  Dim i As Integer
  
  
  i = 0
  myfile = Range("filename").Value
  Set billsheet = ActiveWorkbook.Sheets("Mock Bill")
  
  For Each site In Range("meters")
  
      billsheet.Calculate
      billsheet.Range("$R$10").Value = site
  
      'Create Vertical Page Breaks
      billsheet.VPageBreaks.Add Before:=Range("C3")
      billsheet.VPageBreaks.Add Before:=Range("R3")
  
      'Set Print Area
      Set print_area = billsheet.Range("C3:R50")
  
      Set arr(i) = print_area.Value
  
      i = i + 1
  
  Next site
  
  Array(arr).ExportAsFixedFormat Type:=xlTypePDF, Filename:=myfile
  
  End Sub
  </code></pre>
  
  <p>Thanks in Advance for any assistance!</p>