我正在使用一个数据透视表,它最终会将其值粘贴到单独的工作簿中。问题是过滤器选项卡阻止了第一行,第二行是空白的,我不需要第三行的标题。我也不需要前 3 列,因为报告不需要它们。
我使用的数据每周都会更改,因此行数会有所不同。
'Equitable is the name of the worksheet which was declared earlier in the code
Dim BuysPivot As Worksheet
Dim SummarySCS As Worksheet
Set BuysPivot = Equitable.Sheets("Buys Pivot")
Set SummarySCS = Equitable.Sheets("SCS_Summary")
Dim PivotCt As Long
PivotCt = BuysPivot.Cells(Rows.Count, "D4").End(xlDown).Row '---> Code fails
'1004 error. "Application-defined or object-defined error"
BuysPivot.Range("D4:H" & PivotCt).Copy
SummarySCS.Range("c2").PasteSpecial xlPasteValues
上面的代码应该能够从 D4 向下复制并将其粘贴到相应的工作表中。
预先感谢您的帮助