Consulting

Results 1 to 3 of 3

Thread: how to combine GetItems() - syntax

  1. #1
    VBAX Regular
    Joined
    Sep 2011
    Posts
    22
    Location

    how to combine GetItems() - syntax

    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


    [VBA]
    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
    [/VBA]
    Attached Files Attached Files

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    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?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Sep 2011
    Posts
    22
    Location
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •