ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Count rows in a PivotTable (https://www.excelbanter.com/excel-programming/352239-count-rows-pivottable.html)

Desmond

Count rows in a PivotTable
 
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!

Debra Dalgleish

Count rows in a PivotTable
 
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


Desmond wrote:
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!



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html


Desmond

Count rows in a PivotTable
 
You are a star! Thank you very much!

"Debra Dalgleish" wrote:

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


Desmond wrote:
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!



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html




All times are GMT +1. The time now is 09:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com