Excel 2003 Pivot Table Page Field <> "(All)"

rickincanada

Board Regular
Joined
Aug 31, 2010
Messages
61
Hi there,

I'm attempting to hide a column on a Pivot Table in an Excel 2003 workbook whenever the a couple of the Page Fields don't = "(All)". Here's what I've got so far however I'm sure at first glance you'll see some of my issues. Can someone please help!!

Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
Application.ScreenUpdating = False
If Target.PageField("Type").PivotItems.Value = "(All)" _
And Target.PageField("Time Type").PivotItems.Value = "(All)" _
Me.Cells(1, 4).EntireColumn.Hidden = False
Else
Me.Cells(1, 4).EntireColumn.Hidden = True
End If
Dim z As PivotField
Application.ScreenUpdating = True
End Sub

Thanks so much!

Rick
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi,

Maybe

Code:
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
    Application.ScreenUpdating = False
    If Target.PivotFields("Type").CurrentPage <> "(All)" _
        And Target.PivotFields("Time type").CurrentPage <> "(All)" Then
        Me.Cells(1, 4).EntireColumn.Hidden = True
    Else
        Me.Cells(1, 4).EntireColumn.Hidden = False
    End If
    Dim z As PivotField
    Application.ScreenUpdating = True
End Sub

HTH

M.
 
Upvote 0
You were close...

Here's what I ended up with:

Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
Application.ScreenUpdating = False
If Target.PageFields("Type").CurrentPage.Value = "(All)" _
And Target.PageFields("Time Type").CurrentPage.Value = "(All)" Then
Me.Cells(1, 4).EntireColumn.Hidden = False
Else
Me.Cells(1, 4).EntireColumn.Hidden = True
End If
Dim z As PivotField
Application.ScreenUpdating = True
End Sub

And it works perfect!

Thanks for your help!
 
Upvote 0

Forum statistics

Threads
1,223,238
Messages
6,170,939
Members
452,368
Latest member
jayp2104

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