I think this:
Needs to be:![]()
.ChangePivotCache ThisWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=NewRange)
ThisWorkbook is always the workbook where the code resides.![]()
.ChangePivotCache wb.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=NewRange)
ActiveWorkbook is the active workbook regardless of where the code resides.
wb in this instance has been defined as ActiveWorkbook so we should use this.
Bookmarks