title: Insert excel data before the pivot table
body: <p>I keep getting this error: 
  Run-time error '5':</p>
  
  <p>Invalid procedure call or argument:</p>
  
  <p>I am just learning VBA...&amp; yes, I have searched for the answer on here before I tried to ask this question. First I tried to add single quotes to the TableDestination(however there's no space in the sheet name), &amp; then I tried to refresh the table which I did, no bueno. I also made sure that the pivot table name was unique and not previously used, lastly I came across a solution to remove the Sheets.Add statement and leave TableDestination:="". This worked but when I generate the report it inserts the pivot table before the excel data, and I wanted it the other way around, I'm sure what I am doing wrong is very simple, but I can't seem to find what I need</p>
  
  <pre><code>Sub PostProcessing()
   Dim MainWorksheet As Worksheet
  
   Set MainWorksheet = ActiveWorkbook.Worksheets("Query1")
  
   Dim pt     As PivotTable
   Dim pf     As PivotField
   Dim pi     As PivotItem
   Dim pc     As PivotCache
   Dim ws     As Worksheet
  
   With ActiveWorkbook
      For Each pc In .PivotCaches
          pc.MissingItemsLimit = xlMissingItemsNone
      Next pc
   End With
  
   'Create a pivot table on page Two
  
   Sheets.Add After:=Sheets(Sheets.Count)
  
    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, _
    SourceData:= "Query1!R1C7:R90C8", _
    Version:=xlPivotTableVersion14).CreatePivotTable _
    TableDestination:="Sheet1!R1C1", TableName:= "PTCtable"
  
   With ActiveSheet.PivotTables("PTCtable")'
      With .PivotFields("Assigned To")
         'Set the Row Field
         .Orientation = xlRowField
         .Position = 1
      End With
  
      ActiveSheet.Shapes.AddChart.Select
      ActiveChart.ChartType = xlColumnClustered
   End With
  
  End Sub
  </code></pre>