title: Filter and Save to pdf in VBA
body: <p>I'd like to move through a filter and print out what appears on the filtered page to a pdf file before moving onto the next filter item. The idea driving this is that I need to report school building info for each district in my state. I currently have the data sitting in a table (could easily be a pivot with a slicer if that code works out better) with filters set up as I need. The length of columns will change as the district changes to account for varying sizes. Currently, my code does not work. I need help figuring out why. </p>
  
  <pre><code>Sub ShiftandPrint()
  Dim i As Integer
  i = 1
      For cl = 1 To Columns.Count
          n = WorksheetFunction.CountA(Columns(cl))
      Next
  Do While Cells(3, i).Value &lt;&gt; ""
      With Sheet1
          .AutoFilterMode = False
          .Range("n").AutoFilter
          .Range("n").AutoFilter Field:=1, Criteria1:=Cell(3, i)
      End With
  
  Dim fName As String
  With ActiveSheet
  fName = .Range("A1").Value &amp; .Range("A2").Value
  .ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
          "C:\My Documents\" &amp; fName, Quality:=xlQualityStandard, _
          IncludeDocProperties:=True, IgnorePrintAreas:=False,       OpenAfterPublish:=False
  End With
  i = i + 1
  Loop
  End Sub
  </code></pre>
  
  <p>Thanks for any help!</p>