title: ChangePivotCache giving type mismatch error
body: <p>I have a macro that previously reset the cache of two pivot tables without any error. I'm running into a run time error 13 type mismatch for just 1 of the tables and I do not understand why it's suddenly not working. And for just the one table as well when the code is identical for both tables.</p>
  
  <pre><code>Sub refresh_caches()
  
  Dim cpt As PivotTable, chpt As PivotTable
  Set ca2 = Sheets("claim edit").Range("A2")
  Set cha2 = Sheets("chrg review").Range("A2")
  Set cpc = Range(ca2.End(xlToRight), ca2.End(xlDown))
  Set chpc = Range(cha2.End(xlToRight), cha2.End(xlDown))
  Set cpt = Sheets("Formulas &amp; Pivots").PivotTables("ptClaim")
  Set chpt = Sheets("Formulas &amp; Pivots").PivotTables("ptCharge")
  
  
  cpt.ChangePivotCache ActiveWorkbook. _
          PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
          cpc, Version:=xlPivotTableVersion15)
  
  chpt.ChangePivotCache ActiveWorkbook. _
          PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
          chpc, Version:=xlPivotTableVersion15)
  
  For Each PivotCache In ActiveWorkbook.PivotCaches
      PivotCache.Refresh
      Next
  End Sub
  </code></pre>
  
  <p>The run time error is hitting on the <code>changepivotcache</code> code. When I step through and skip to the second code for <code>chpt</code>, it updates that table fine.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p><strong>Edit</strong> The error appears after the data source, which is a data connection, is refreshed. I get the same error even when referencing the range directly as the <code>sourcedata</code>. Though if i manually change the data source the pivot table updates just fine.</p>
  
  <p>Whats also odd that when referencing the full range of data directly it will throw the error, but if I do not reference every row it will update the table.</p>
  
  <p><strong>NEW Edit</strong> I believe I've identified the line causing my issue, though I do not fully understand why or if this is what caused the issue previously. I narrowed the issue down to the exact cell and it seems to happen whenever any cell in the range contains more than 255 characters. I tested this with additional cells in the range by adding text to the cell and prompted the error, likewise I could prevent the error by ensuring the text of the cell contained no more than 255 chars.</p>
  
  <p>Why is this? I can manually select the data range and use it as my pivotcache but I cannot get the code to do the exact same thing. Found some issues with cells exceeding 255 chars on google but am still baffled as I'm not referencing the cell specifically, just including it in a range. Would really appreciate some insight on this, especially so I can find a workaround for the next time the data pulls a cell value exceeding this limit.</p>