Move "(blank)" to end of filtered Pivot Range

tlc_in_OK

Board Regular
Joined
Jun 27, 2011
Messages
56
I have a macro that filters a pivot table, resorts, then copies data to another area for more calculations. I need to always move the "(blank)" elements of the first column of the pivot table ("A") to the bottom of the range once filtered. I know I can use:

ActiveSheet.PivotTables("PivotTable1").PivotFields("Offer_to_Target_Pct").PivotItems("(blank)").Position = ????

But for the ????, how do I set the variable range of a filtered Pivot field?
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Code:
Private Sub example()

    Dim pvt As PivotTable
    
    Set pvt = ActiveSheet.PivotTables("PivotTable1")
    
    pvt.PivotFields("Offer_to_Target_Pct").PivotItems("(blank)").Position = _
        pvt.PivotFields("Offer_to_Target_Pct").PivotItems.Count

End Sub
 
Upvote 0
Code:
Private Sub example()

    Dim pvt As PivotTable
    
    Set pvt = ActiveSheet.PivotTables("PivotTable1")
    
    pvt.PivotFields("Offer_to_Target_Pct").PivotItems("(blank)").Position = _
    pvt.PivotFields("Offer_to_Target_Pct").DataRange.Count

End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top