How to find the last column or last row in a pivottable range

Joined
Oct 11, 2006
Messages
3
Reaction score
0
To find the last row used by the pivottable I used the Following expression:

LastLine = UBound(ActiveSheet.PivotTables(1).RowRange.Value2) + ActiveSheet.PivotTables(1).DataLabelRange.row

It returns, for exemple, LastLine = 1005, meaning that the line #1005 is the last line used by the Pivottable

To find the last column used by the pivottable I used the Following expression:

LastCol = Range(ActiveSheet.PivotTables(1).TableRange1.Address).Columns.Count + Range(ActiveSheet.PivotTables(1).DataLabelRange.Address).Column - 1

It returns, for exemple, LastCol = 5, meaning that the column "E" is the last column used by the Pivottable

I hope it's useful to someone...

DartVeiga.
 
Back
Top