LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default error with setting "Items.Visible = True"

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
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
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
Typing "true" excel 2007 change it to "TRUE" Mr. T Excel Discussion (Misc queries) 2 April 11th 07 01:24 PM
Error when create chartobject on line ".HasTitle = True" tskogstrom Charts and Charting in Excel 2 November 23rd 06 07:44 PM
VBA setting formula for a cell causes "Wrong data type" error undercups Excel Discussion (Misc queries) 4 September 17th 06 10:14 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


All times are GMT +1. The time now is 04:47 AM.

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

About Us

"It's about Microsoft Excel"