Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Cydney
 
Posts: n/a
Default Pivot Table using "LIKE" code

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 "Page"
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 "CODES LIKE NSR*".

Can I do that in VB for a pivot table?
--
THX cs
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bernie Deitrick
 
Posts: n/a
Default Pivot Table using "LIKE" code

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("PivotTable1").PivotFields ("Code")
For Each myPI In .PivotItems
myPI.Visible = True
Next myPI

For Each myPI In .PivotItems
If myPI.Name Like "NSR*" Then
myPI.Visible = True
Else
myPI.Visible = False
End If
Next myPI
End With
End Sub



"Cydney" wrote in message
...
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
"Page"
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 "CODES LIKE NSR*".

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



Reply
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
Using a Pivot Table Calculated Field to get a Unique Count Mike Struckman Excel Worksheet Functions 1 November 22nd 05 05:32 PM
Pivot Table VBA code to move a row uclawarren Excel Discussion (Misc queries) 0 October 10th 05 08:49 PM
Pivot -- want to use Max and Sum in same table Dave Excel Worksheet Functions 1 July 13th 05 04:37 AM
Pivot Table Problems Rachel Gonsior Excel Discussion (Misc queries) 3 March 21st 05 07:24 PM
Printing a Pivot Table from code - Excel 2003 Newbie Excel Discussion (Misc queries) 4 January 5th 05 04:10 PM


All times are GMT +1. The time now is 06:08 AM.

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

About Us

"It's about Microsoft Excel"