Find the End of a Pivot table

L

Looping through

I need to find the end of a Pivot table I call "Won" the table sorts orders
out and is constantly growing. I need to find the last cell of that table at
any given time after it is filtered so I can add some notes and other info to
the bottom. I have tried range names but when the table grows it consumes my
Range Name as well. Can the cell with the range name move with the growing
table?

thanks
Peter
 
J

Jon Peltier

Sub GetLastPTCell()
Dim rLastCell As Range
With ActiveSheet.PivotTables(1).TableRange1
Set rLastCell = .Offset(.Rows.Count - 1, .Columns.Count - 1).Resize(1,
1)
End With
End Sub

- Jon
 
L

Looping through

Jon, thanks for the responce, but the last cell of my pivot table was not
found. The code runs but the active cell does not get selected.

I added ActiveCell.Offset(0, -1).Range("A1").Select to your code to test.
this works but the active cell selected at the top of the PT not the bottom.

Peter
 
J

Jon Peltier

To select the last cell of the pivot table:

Sub GetLastPTCell()
Dim rLastCell As Range
With ActiveSheet.PivotTables(1).TableRange1
Set rLastCell = .Offset(.Rows.Count - 1, .Columns.Count - 1).Resize(1,
1)
End With

rLastCell.Select

End Sub


- Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top