我试图弄清楚当数据使用 VBA 更改时如何将我的数据透视表源数据更新到行尾。我当前的代码如下:
Dim shBrandPivot As Worksheet
Dim shCurrentWeek As Worksheet
Dim shPriorWeek As Worksheet
Dim shPivot As Worksheet
Dim lr As Long
Set shBrandPivot = ActiveWorkbook.Sheets("Brand Pivot")
Set shCurrentWeek = ActiveWorkbook.Sheets("Current Week")
Set shPriorWeek = ActiveWorkbook.Sheets("Prior Week")
Set shPivot = ActiveWorkbook.Sheets("Pivot")
lr = shCurrentWeek.Range("A" & Rows.Count).End(xlUp).Row
With ActiveWorkbook.Sheets("Pivot").Activate
ActiveSheet.PivotTableWizard SourceType:=xlDatabase, SourceData:="CurrentWeek!A3:X & lr"
End With
我得到的错误是运行时错误 1004:无法打开数据透视表源文件:E:\offline\KXM2103\Data\CurrentWeek