TheRedCardinal
Active Member
- Joined
- Jul 11, 2019
- Messages
- 252
- Office Version
- 365
- 2021
- Platform
- Windows
I am trying to determine the number of rows of data in a Pivot field.
My code looks like this:
This returns a value for "Counter" of 76. My table has 73 rows of data. It also has a Grand Total Row, and two rows at the top for the various names = 76.
When I re-run my code with TableRange2.Rows.Count instead, I also get 76.
Surely these 2 numbers cannot be the same? I thought TableRange1 would be data only, and TableRange2 for the whole page?
My code looks like this:
Code:
Sub LookupCommon()
'A sub to populate the CSV file with common data
Set WS1 = Sheets("5. Final CSV")
Set WS2 = Sheets("4. PivotTable")
Set MyPivot = WS2.PivotTables(1)
Counter = MyPivot.TableRange1.Rows.Count
End Sub
This returns a value for "Counter" of 76. My table has 73 rows of data. It also has a Grand Total Row, and two rows at the top for the various names = 76.
When I re-run my code with TableRange2.Rows.Count instead, I also get 76.
Surely these 2 numbers cannot be the same? I thought TableRange1 would be data only, and TableRange2 for the whole page?