Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Visible PivotItems matching criteria

How can I use -
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Ref")
..PivotItems("QM").Visible = True

What I want to do is show anything that matches QM (i.e. "QM - 1" or "QM - 2")

Any ideas, I can't use a * or LIKE in the code can I?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Visible PivotItems matching criteria

Hi Westg,

Check the value of the pivotitem using the LIKE operator. The LIKE operator
is case sensitive. Something like this should work:

Sub test()
Dim pf As PivotField
Dim pi As PivotItem

Set pf = ActiveSheet.PivotTables("PivotTable1").PivotFields ("Ref")

For Each pi In pf.PivotItems
If Not (pi.Value Like "*QM*") Then
pi.Visible = False
End If
Next

Set pf = Nothing
Set pi = Nothing
End Sub

Every item with a QM in the name should be visible and everything else
should be hidden

Regards,
Mike

"westg" wrote:

How can I use -
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Ref")
.PivotItems("QM").Visible = True

What I want to do is show anything that matches QM (i.e. "QM - 1" or "QM - 2")

Any ideas, I can't use a * or LIKE in the code can I?

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
Controlling Pivotitems.visible sxhwabbiemike Excel Discussion (Misc queries) 0 January 21st 09 03:09 AM
Pivot Change PivotItems - Visible/Hide with VBA [email protected] Excel Worksheet Functions 3 January 6th 07 12:26 AM
Always keep the same 4 PivotItems visible Martin[_21_] Excel Programming 2 April 27th 05 10:17 AM
PivotItems.Count is 0 when items are visible on the sheet iD Excel Programming 4 March 3rd 05 02:07 AM
Excel Pivot Tables, Page Fields, Visible PivotItems, Activation Ananda Sim Excel Programming 1 September 10th 04 01:57 AM


All times are GMT +1. The time now is 06:17 PM.

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"