title: Excel VBA Changing Data Source for Pivot Table
body: <p>Okay, I have sifted through tons of posts and cannot get my code to run. I am trying to create a reconciliation report, which I have running just fine. The problem comes when I am trying to take each month's report and paste it into a master reconciliation file. I have everything working perfectly, except I cannot for the life of me figure out WHY my pivot table source won't change.</p>
  
  <p>The error I am getting with the code as is:</p>
  
  <blockquote>
    <p>Run-time error '1004': Application-defined or object-defined error</p>
  </blockquote>
  
  <p>Any suggestions? :-\</p>
  
  <pre><code>    Dim SrcData As String
      Dim PivTbl As PivotTable
  
      SrcData = ActiveSheet.Name &amp; "!" &amp; Range("$A$1:$H$" &amp; LastRow).Address(ReferenceStyle:=xlR1C1)
  
      On Error Resume Next
          Set PivTbl = Sheets("Report").PivotTables("ReportPivot")
      On Error GoTo 0
          If PivTbl Is Nothing Then
              'create pivot
          Else
              ActiveWorkbook.PivotTables(PivTbl).ChangePivotCache ActiveWorkbook. _
              PivotCaches.Create(SourceType:=xlDatabase, SourceData:=SrcData, _
              Version:=xlPivotTableVersion15)
  
              PivTbl.RefreshTable
          End If
  </code></pre>