close

I have an automated pivot table that comes from our corporate group which I
manipulate each month into other reports. It has a CODE field in the quot;Pagequot;
section of the pivot table that I use to see different groups of information.

I would like to programmatically (i.e. in VB code) select a group to display
that uses a wildcard. For example, I have data showing codes like NSR001,
NSR002, NSR003 .. etc. and NTR001, NTR002 .. etc. I would like to select all
the NSR groups without having to choose each one that is on this worksheet
because each month the codes might vary a bit. Some months might not have
NSR003. I would like to use something like quot;CODES LIKE NSR*quot;.

Can I do that in VB for a pivot table?
--
THX cs

Cydney,

Try a macro like the one below. Change the names as appropriate.

HTH,
Bernie
MS Excel MVP

Sub Macro1()
Dim myPI As PivotItem

With ActiveSheet.PivotTables(quot;PivotTable1quot;).PivotFields (quot;Codequot;)
For Each myPI In .PivotItems
myPI.Visible = True
Next myPI

For Each myPI In .PivotItems
If myPI.Name Like quot;NSR*quot; Then
myPI.Visible = True
Else
myPI.Visible = False
End If
Next myPI
End With
End Sub
quot;Cydneyquot; gt; wrote in message
...
gt;I have an automated pivot table that comes from our corporate group which I
gt; manipulate each month into other reports. It has a CODE field in the
gt; quot;Pagequot;
gt; section of the pivot table that I use to see different groups of
gt; information.
gt;
gt; I would like to programmatically (i.e. in VB code) select a group to
gt; display
gt; that uses a wildcard. For example, I have data showing codes like NSR001,
gt; NSR002, NSR003 .. etc. and NTR001, NTR002 .. etc. I would like to select
gt; all
gt; the NSR groups without having to choose each one that is on this worksheet
gt; because each month the codes might vary a bit. Some months might not have
gt; NSR003. I would like to use something like quot;CODES LIKE NSR*quot;.
gt;
gt; Can I do that in VB for a pivot table?
gt; --
gt; THX cs

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()