Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ri Ri is offline
external usenet poster
 
Posts: 3
Default VBA Excel PivotTable Drop Down Help

Hi,

Okay, so I'm primarily an Access/Web developer, but a client has asked
us to use Microsoft Access to automatically set filter values on their
Excel PivotTables. This has been going okay until I hit a snag. Most
of the filters are single value - meaning there is a drop-down list of
(All), Value1, Value2, etc. However, there are a couple which are
multi-select. There is a drown down list, and instead of selecting one
of the items, you can click on a little checkbox to select 1-many of
the items.

I need to figure out how to set THESE items programmatically. Any
ideas?

Thanks!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default VBA Excel PivotTable Drop Down Help

Sub ShowHidePivotItems()

Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem

' Set reference to pivot table
Set pt = ActiveSheet.PivotTables(1)
' Set reference to the pivot field with dates to show/hide
Set pf = pt.PivotFields("Color")

For Each pi In pf.PivotItems

If pi.Value = "orange" Or pi.Value = "green" Then
pi.Visible = True
Else
pi.Visible = False
End If
Next

End Sub

"Ri" wrote in message
oups.com...
Hi,

Okay, so I'm primarily an Access/Web developer, but a client has asked
us to use Microsoft Access to automatically set filter values on their
Excel PivotTables. This has been going okay until I hit a snag. Most
of the filters are single value - meaning there is a drop-down list of
(All), Value1, Value2, etc. However, there are a couple which are
multi-select. There is a drown down list, and instead of selecting one
of the items, you can click on a little checkbox to select 1-many of
the items.

I need to figure out how to set THESE items programmatically. Any
ideas?

Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
Ri Ri is offline
external usenet poster
 
Posts: 3
Default VBA Excel PivotTable Drop Down Help

Thanks!

However, when I try and do this, I get an error that says I'm unable to
set the visible property of the item. Any ideas?

Thanks again!

Tim Zych wrote:
Sub ShowHidePivotItems()

Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem

' Set reference to pivot table
Set pt = ActiveSheet.PivotTables(1)
' Set reference to the pivot field with dates to show/hide
Set pf = pt.PivotFields("Color")

For Each pi In pf.PivotItems

If pi.Value = "orange" Or pi.Value = "green" Then
pi.Visible = True
Else
pi.Visible = False
End If
Next

End Sub

"Ri" wrote in message
oups.com...
Hi,

Okay, so I'm primarily an Access/Web developer, but a client has asked
us to use Microsoft Access to automatically set filter values on their
Excel PivotTables. This has been going okay until I hit a snag. Most
of the filters are single value - meaning there is a drop-down list of
(All), Value1, Value2, etc. However, there are a couple which are
multi-select. There is a drown down list, and instead of selecting one
of the items, you can click on a little checkbox to select 1-many of
the items.

I need to figure out how to set THESE items programmatically. Any
ideas?

Thanks!


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default VBA Excel PivotTable Drop Down Help

What is the value of the item, and does that really exist in the data? It's
possible there are old values in the pivotfield list that no longer exist in
the data source.

Try this modified version. It deletes unused pivotitems first.

Sub ShowHidePivotItems()

Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem

Set pt = ActiveSheet.PivotTables(1)

Set pf = pt.PivotFields("Color")

On Error Resume Next
' Remove old items first
For Each pi In pf.PivotItems
pi.Delete
Next
On Error GoTo 0
pt.RefreshTable

For Each pi In pf.PivotItems
If pi.Value = "blue" Then 'Or pi.Value = "green" Then
pi.Visible = True
Else
pi.Visible = False
End If
Next

pt.RefreshTable

End Sub

"Ri" wrote in message
oups.com...
Thanks!

However, when I try and do this, I get an error that says I'm unable to
set the visible property of the item. Any ideas?

Thanks again!

Tim Zych wrote:
Sub ShowHidePivotItems()

Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem

' Set reference to pivot table
Set pt = ActiveSheet.PivotTables(1)
' Set reference to the pivot field with dates to show/hide
Set pf = pt.PivotFields("Color")

For Each pi In pf.PivotItems

If pi.Value = "orange" Or pi.Value = "green" Then
pi.Visible = True
Else
pi.Visible = False
End If
Next

End Sub

"Ri" wrote in message
oups.com...
Hi,

Okay, so I'm primarily an Access/Web developer, but a client has asked
us to use Microsoft Access to automatically set filter values on their
Excel PivotTables. This has been going okay until I hit a snag. Most
of the filters are single value - meaning there is a drop-down list of
(All), Value1, Value2, etc. However, there are a couple which are
multi-select. There is a drown down list, and instead of selecting

one
of the items, you can click on a little checkbox to select 1-many of
the items.

I need to figure out how to set THESE items programmatically. Any
ideas?

Thanks!




  #5   Report Post  
Posted to microsoft.public.excel.programming
Ri Ri is offline
external usenet poster
 
Posts: 3
Default VBA Excel PivotTable Drop Down Help

Actually, I figured out that I needed to set do this:

pi.AutoSort xlManual, pf.SourceName
'Code Here
pi.AutoSort xlAscending, pf.SourceName

And it worked fine.

Thanks!
Tim Zych wrote:
What is the value of the item, and does that really exist in the data? It's
possible there are old values in the pivotfield list that no longer exist in
the data source.

Try this modified version. It deletes unused pivotitems first.

Sub ShowHidePivotItems()

Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem

Set pt = ActiveSheet.PivotTables(1)

Set pf = pt.PivotFields("Color")

On Error Resume Next
' Remove old items first
For Each pi In pf.PivotItems
pi.Delete
Next
On Error GoTo 0
pt.RefreshTable

For Each pi In pf.PivotItems
If pi.Value = "blue" Then 'Or pi.Value = "green" Then
pi.Visible = True
Else
pi.Visible = False
End If
Next

pt.RefreshTable

End Sub

"Ri" wrote in message
oups.com...
Thanks!

However, when I try and do this, I get an error that says I'm unable to
set the visible property of the item. Any ideas?

Thanks again!

Tim Zych wrote:
Sub ShowHidePivotItems()

Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem

' Set reference to pivot table
Set pt = ActiveSheet.PivotTables(1)
' Set reference to the pivot field with dates to show/hide
Set pf = pt.PivotFields("Color")

For Each pi In pf.PivotItems

If pi.Value = "orange" Or pi.Value = "green" Then
pi.Visible = True
Else
pi.Visible = False
End If
Next

End Sub

"Ri" wrote in message
oups.com...
Hi,

Okay, so I'm primarily an Access/Web developer, but a client has asked
us to use Microsoft Access to automatically set filter values on their
Excel PivotTables. This has been going okay until I hit a snag. Most
of the filters are single value - meaning there is a drop-down list of
(All), Value1, Value2, etc. However, there are a couple which are
multi-select. There is a drown down list, and instead of selecting

one
of the items, you can click on a little checkbox to select 1-many of
the items.

I need to figure out how to set THESE items programmatically. Any
ideas?

Thanks!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
PivotTable Drop-Down Un-Checked Item Missing PW1116 Excel Worksheet Functions 1 October 4th 07 11:30 PM
Data values WON'T DELETE in PivotTable drop-downs Natalie 1229 Excel Discussion (Misc queries) 3 March 27th 06 09:18 PM
Excel 2000 / How clear drop-down list in Pivottable? No Name Excel Programming 2 August 18th 04 11:02 PM
Dynamic Selection of Pivottable Drop Down Items Pat[_8_] Excel Programming 0 November 7th 03 10:01 PM
Help - PivotTable Drop-down not Sorting Rob Rutherford Excel Programming 1 August 6th 03 12:47 PM


All times are GMT +1. The time now is 06:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"