I have the following code which worked at some point but now throws me an error at ".SourceData = rng.Address(True, True, xlR1C1, True)"
Dim rng As Range
Set rng = ActiveSheet.Range("A1:F" & LastRow)
Set shTotalsPivot = ActiveWorkbook.Sheets("Totals Pivot")
With shTotalsPivot.PivotTables(1).PivotCache
.SourceData = rng.Address(True, True, xlR1C1, True)
.Refresh
End With
Could you please advise what I am doing incorrectly. I simply want to change a source in the existing pivot table to the new sheet which will an active sheet in this case. Thanks