View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
GS[_6_] GS[_6_] is offline
external usenet poster
 
Posts: 1,182
Default Pivot Table run-time error 1004 (PivotField class)

Hi Garry,

It's been a while since I've posted, and it's always a pleasure to
hear from you. I plugged this in, and it does indeed run; however,
unfortunately, it's still about as slow as the other other code. I
think it's because it's actually loading the pivot table with every
iteration of the loop. And there are over 300 pivot items to load.

When I actually go to the pivot table and select a catalog number from
the slicer, it loads in just a couple seconds. Is there a reason I'm
not able to simply clear the filters and load the catalog number that
gets put into the variable from the double-click event?

Thanks Garry!

Frank

On Fri, 06 Apr 2018 07:35:45 -0400, GS wrote:

Oops.., forgot to refresh...

Dim sCatNum$, vItem
If (Target.Column = 4) Then
'Cancel EditMode and get Catalog Number
sCatNum = Target.Value: Cancel = True
With Sheets("Slicers (all)").PivotTables("PivotSlicer")
With .PivotFields("Catalog #")
.ClearAllFilters
Application.EnableEvents = False
For Each vItem In .PivotItems
vItem.Visible = (vItem = sCatNum)
Next 'vItem
Application.EnableEvents = True
End With '.PivotFields("Catalog #")
.RefreshTable
End With 'Sheets("Slicers (all)").PivotTables("PivotSlicer")
End If '(Target.Column = 4)


The pivot table functions are written in C++ which is *orders of magnitude*
faster than VB. I was hoping the link I posted would contain some way to
automate the slicer. Optionally, turn on the macro recorder and see what code
(if any) it generates when you do it manually.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion