提问人:Hari Prakash 提问时间:8/31/2023 最后编辑:JohnMHari Prakash 更新时间:8/31/2023 访问量:15
无法使用以下代码更改透视数据源,未收到错误
Unable to change the pivot data source with below code, not getting error
问:
我正在尝试更改 Excel 文件中所有数据透视表的数据源。假设数据范围相同,并且数据位于同一文件中。数据范围分配给字符串变量 。newDataSource
For Each ws In SourceWorkbook.Worksheets
For Each pt In SourceWorkbook.PivotTables
If Not bCreated Then
pt.ChangePivotCache SourceWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=newDataSource)
Set pc = pt.PivotCache
bCreated = True
Else
If pt.CacheIndex <> pc.Index Then pt.CacheIndex = pc.Index
End If
Next pt
Next ws
答: 暂无答案
评论