VBA to edit PivotTable

ChrisMcIntyre

New Member
Joined
Jan 6, 2022
Messages
37
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi there, and right off the bat, I am still a total newbie to VBA and now Pivot Tables too.

I have the following code setup in my workbook, and it's doing everyting I want except hide the "(blank)" entries.
It should refesh all the tables first, then reset the filters in "Row" field so all items are selected, then it should uncheck anything labelled "(blank)".
Any ideas how I can hide those pesky blanks please?

Thanks, Chris.

Sub REFRESH_PIVOTS()

'Refresh PivotTables

ActiveWorkbook.REFRESHALL

Dim pt As PivotTable
Dim pf As PivotField

Set pt = ActiveSheet.PivotTables("PivotTable9")
Set pf = pt.PivotFields("Row")
With pf
.ClearAllFilters
On Error Resume Next
.PivotItems("(blank)").Visible = False
On Error GoTo 0

End With

End Sub
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Forum statistics

Threads
1,215,676
Messages
6,126,170
Members
449,296
Latest member
tinneytwin

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