我想在一个名为pivotTable1的pivotTable中找到最后一行。
Sub lastrowPT ()
Dim pt As PivotTable
Dim lastRow As Long
Set pt = Sheet1.PivotTables(1)
lastRow = pt.TableRange2.Cells(1).row + pt.TableRange2.Rows.count - 1
End sub
但是,我它是什么工作。有什么好办法吗?
你可以这样做。
With Sheet1.PivotTables(1).TableRange2
LastRow = .Rows(.Rows.Count).Row
End With
数据表Row2的最后一个单元格。
Dim rw As Range
With Sheet1.PivotTables(1).DataBodyRange
Set rw = .Rows(2)
End With
rw.Cells(rw.Cells.Count).Select
https:/peltiertech.comreferencing-pivot-table-ranges-in-vba。