PDA

View Full Version : how to combine GetItems() - syntax



JayJay6
09-21-2011, 04:09 AM
Hi,

Can anyone plaese help me with the syntax:

The script below is part of a larger script (attachment) which filter a pivottable using text cells.

Everything works fine a long as I filter one object (Field)on one cell (rng1). (="VecItems1")

Now I try to add a second criteria (Field2, rng2) (se below), which doesn't make any errors, but it doesn't work either. Therefore:

Does anyone know how to combine "VecItems1" and "VecItems2" ? And the two "Call"-functions following the VecItems statements ?

Thanks



If Not pt Is Nothing Then

pt.ManualUpdate = True
Application.EnableEvents = False
Application.ScreenUpdating = False

Dim Field As PivotField, Field2 As PivotField

Set Field = pt.PivotFields("Region")
Set Field2 = pt.PivotFields("Name")

Field.ClearAllFilters
Field.EnableItemSelection = False

If Range("rng1", "rng2").Text = "(All)" Then
Call ResetAllItems(pt, Range("Region", "Name"))

Else

' vecItems1 = GetItems(Worksheets("Sheet1").Range("A2:A20"), rng1.Text)
vecItems2 = GetItems(Worksheets("Sheet1").Range("A2:A20"), rng2.Text)

' Call SelectPivotItem(Field, vecItems1)
Call SelectPivotItem(Field2, vecItems2)

End If
pt.RefreshTable
End If

Bob Phillips
09-21-2011, 09:06 AM
What exactly are you trying to do? Filter one item with more than one selection or filter two items each with one of the selections?

JayJay6
09-21-2011, 02:40 PM
Hi Xld,

I am trying to make one cell, rng1, to filter on the item "Region", and make one cell, rng2, filter on the item "Name". Both items is in the same Pivottable.

example:
The table in the attachment "Test2.2" is very small, but let us say it was very big, and I want to filter my table with all the "Regions" where the letter "K" exists (rng1= *K*), and in these regions, I want to filter all the "Names" where "4" exists (rng2=*4*).

You have earlier enriched my script with the wildcard functionailty, and it works excellent with one filter/cell, but I need two (or more).

br,
Jakob