David Van der Vieren
David Van der Vieren

Reputation: 275

Trying to select a entire range under a row label in a pivot table

I am trying to select all the rows under a specific row label but with my code I am only able to select the first Row under each row label. Any suggestions would be greatly appreciated, here is my code.

 Sub ttest()
 Dim pt As PivotTable
 Set pt = Sheets("Report").PivotTables("PivotTable1")

 pt.PivotFields("Pillar").PivotItems("CL").DataRange.EntireRow.Select

 End Sub

enter image description here

Upvotes: 0

Views: 4359

Answers (1)

Vikas
Vikas

Reputation: 805

You can use this code to copy the rows. Should work on your existing set of code:

PT.PivotSelect "'CL' Rows[All]", xlDataAndLabel + xlFirstRow, True

Copied through Macro Recorder.

Edit: You can always use offset to edit the current selection. I mean to increase or decrease number of selected rows.

Thanks, V

Upvotes: 1

Related Questions