I have create macro to change the source of Pivot in all worksheets. In my workbook there has sheets one with CityName, like 'Mumbai'(Which is pivot sheet) and source data sheet with Name 'MumbaiData'(which is source sheet), It's popping an error bcz sometime i don't have source sheet. How could i handle this Error to resume to next sheet's Pivot
My code
Sub pivotsourcechange()
Dim ws As Worksheet
Dim pt As PivotTable
For Each ws In ActiveWorkbook.Worksheets
For Each pt In ws.PivotTables
ws.PivotTableWizard SourceType:=xlDatabase, SourceData:=Worksheets(ActiveSheet.Name & " PV").UsedRange
Next pt
Next ws
End Sub