PC Review


Reply
Thread Tools Rate Thread

Adding Report Filters to Excel Pivot Tables via VB.

 
 
Andreas Lundgren
Guest
Posts: n/a
 
      17th Oct 2011
Hi!

I'm writing my first VB script for Excel in order to generate nice
Pivot tables from loads of data.

When the Pivot table is generated, I want to add a "Report Filter" on
one parameter.

Straight forward macro after recording is the following; however, it
has a major problem:

ActiveSheet.ChartObjects("Chart 1").Activate
ActiveSheet.PivotTables("PivotTable1").PivotFields("Result").CurrentPage
= "FAIL"

The problem occurs when the Pivot field "Result" doesn't contain any
item with the value "FAIL", this causes a runtime error. (Sometime the
data is all correct, believe it or not... ;-) )

Is there a way to first check if it contains any "FAIL" (and then only
set "CurrentPage" if it does)?

Best Regards,
Andreas
 
Reply With Quote
 
 
 
 
isabelle
Guest
Posts: n/a
 
      18th Oct 2011
hi Andreas,

With ActiveSheet.PivotTables(1).PivotFields("Result")
For Each pti In .PivotItems
If pti = "FAIL" Then .CurrentPage = "FAIL"
Next
End With


--
isabelle

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying report filters on Excel Pivot Tables Bound Microsoft Excel Misc 0 15th Apr 2010 04:34 PM
Pivot Table filters, especially DATE filters chris Microsoft Excel Worksheet Functions 0 27th Aug 2008 04:33 AM
Building pivot tables in Excel 2007 based on existing pivot tables? jj.jigga.johns@gmail.com Microsoft Excel Misc 4 26th Dec 2007 09:05 PM
Filters *SOS* Filters *SOS* Filters *SOS* =?Utf-8?B?dmFsZGFpd2F5?= Microsoft Access Queries 1 30th Aug 2007 03:48 AM
How does the term 'pivot' apply to Excel's Pivot tables and Pivot. =?Utf-8?B?c3R2ZXJtb250?= Microsoft Excel Misc 1 17th Feb 2005 02:34 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:14 PM.