Count rows in a PivotTable

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am having trouble of counting the number of rows in PivotTable, I have
tried to use
Worksheets("PivotTable").PivotTables("TimePivot").PivotFields("Name").PivotItems.Count,
but it does not necessarily give the correct answer, any suggestions, thanks
in advance!
 
You can count the rows in the tableranges, e.g.:

Dim pt As PivotTable
Set pt = Worksheets("PivotTable").PivotTables("TimePivot")
MsgBox pt.TableRange1.Rows.Count
MsgBox pt.TableRange2.Rows.Count 'includes page area
 
You are a star! Thank you very much!

Debra Dalgleish said:
You can count the rows in the tableranges, e.g.:

Dim pt As PivotTable
Set pt = Worksheets("PivotTable").PivotTables("TimePivot")
MsgBox pt.TableRange1.Rows.Count
MsgBox pt.TableRange2.Rows.Count 'includes page area
 

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

Back
Top