LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Using macro to switch 'page' in a pivot table?

Hi All,

I have to following simple macro which updates two pivot tables with data
and only shows data relating to a particular project ID 'a':

Sub Macro1()

Sheets("CONTROLS").Select
a = Range("B4").Value

Sheets("Labour Costs").Select
ActiveSheet.PivotTables("PivotTable2").PivotCache. Refresh
ActiveSheet.PivotTables("PivotTable2").PivotFields ("Project
No").CurrentPage = a


Sheets("Non-Labour Costs").Select
ActiveSheet.PivotTables("PivotTable1").PivotCache. Refresh
ActiveSheet.PivotTables("PivotTable1").PivotFields ("Project
ID").CurrentPage = a

Sheets("CONTROLS").Select

End Sub


In some cases the value 'a' doesn't exist in the data range that the pivot
tables are referring to (no costs on the project etc). Is there any way to
force the pivot tables to show as empty as opposed to throwing an error or a
dummy number with another project ID's data?

Many thanks!
Marc
 
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
Macro to select dates in the page field of a pivot table [email protected] Excel Programming 2 November 21st 06 12:43 AM
Pivot Table Page Area selections in a macro norrislaketn Excel Programming 4 March 29th 06 08:40 PM
Pivot table page field switch to (all) if my criteria is not avail Angus Excel Discussion (Misc queries) 0 July 30th 05 05:06 AM
Changing a pivot table page or data set by using a macro [email protected] Excel Programming 1 June 16th 05 01:01 AM
VBA Code for a pivot table to open database and to reference table current page Pete Straman Straman via OfficeKB.com Excel Programming 0 February 21st 05 03:57 AM


All times are GMT +1. The time now is 04:21 PM.

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

About Us

"It's about Microsoft Excel"