Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I had to add capability for our users to check/uncheck all
items in pivot table field. (excel 2000). By searching this webisite I found the code that I needed, but was having problems with setting items.visible to True. Based on additional reading I found out that some people resolved this problem by setting the sort for the field manually. I tried to do that within the macro (set sort to manual, check all, and then set sort back to what it was), but excel is still complaining about it. Please let me know if you can help. Below is the macro itself Thanks -------------------------------------------------- Sub SelectAllItems() Dim pt As PivotTable Dim Items As PivotItem Dim fieldName As String Dim i As Integer, ICount As Integer, PCount As Integer, CCount As Integer Dim intASO As Integer Dim pf As PivotField Application.DisplayAlerts = False Application.ScreenUpdating = True Set pt = ActiveSheet.PivotTables(1) Set pf = pt.PivotFields(ActiveCell.Value) With pt CCount = 0 PCount = pf.PivotItems.Count ..ManualUpdate = True intASO = pf.AutoSortOrder If PCount 0 Then pf.AutoSort xlManual, pf.SourceName For Each Items In pf.PivotItems CCount = CCount + 1 If CCount PCount Then Exit For 'This is done to exit before unchecking the last item. One item must be left checked to prevent an excel error End If If Items.Visible < True Then Items.Visible = True Next ..ManualUpdate = False End With pf.AutoSort intASO, pf.SourceName Application.DisplayAlerts = True Application.ScreenUpdating = False End Sub -------------------------------------------------- |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
change "true" and "false" to "availble" and "out of stock" | Excel Worksheet Functions | |||
Typing "true" excel 2007 change it to "TRUE" | Excel Discussion (Misc queries) | |||
Error when create chartobject on line ".HasTitle = True" | Charts and Charting in Excel | |||
VBA setting formula for a cell causes "Wrong data type" error | Excel Discussion (Misc queries) | |||
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next | New Users to Excel |