Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default pivot table macro with a filtering variable

I have a problem. I will be very glad for any help.

I have a pilot table where tthe data source is obtained from an out source named "CONNECTION1". The below code is obtained by macro saving. It works fine.


Sub Macro1()
ActiveSheet.PivotTables("PivotTable1").PivotFields ( _
"[CONNECTION1].[UWY].[UWY]").ClearAllFilters
ActiveSheet.PivotTables("PivotTable1").PivotFields ( _
"[CONNECTION1].[UWY].[UWY]").CurrentPageName = _
"[CONNECTION1].[UWY].&[2012]"
End Sub

However, I want to define a "z"" variable which will be declared for filtering "year". The updated code is:

Sub Macro1()
z=2012
ActiveSheet.PivotTables("PivotTable1").PivotFields ( _
"[CONNECTION1].[UWY].[UWY]").ClearAllFilters
ActiveSheet.PivotTables("PivotTable1").PivotFields ( _
"[CONNECTION1].[UWY].[UWY]").CurrentPageName = _
"[CONNECTION1].[UWY].&[z]"
End Sub

However, I get an error. I tried many combinatios but I could not solve the problem. Thanks a lot.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default pivot table macro with a filtering variable

hi,

may be:

"[CONNECTION1].[UWY].&[" & z & "]"

isabelle

Le 2014-09-11 12:42, oercim a écrit :
I have a problem. I will be very glad for any help.

I have a pilot table where tthe data source is obtained from an out source named "CONNECTION1". The below code is obtained by macro saving. It works fine.


Sub Macro1()
ActiveSheet.PivotTables("PivotTable1").PivotFields ( _
"[CONNECTION1].[UWY].[UWY]").ClearAllFilters
ActiveSheet.PivotTables("PivotTable1").PivotFields ( _
"[CONNECTION1].[UWY].[UWY]").CurrentPageName = _
"[CONNECTION1].[UWY].&[2012]"
End Sub

However, I want to define a "z"" variable which will be declared for filtering "year". The updated code is:

Sub Macro1()
z=2012
ActiveSheet.PivotTables("PivotTable1").PivotFields ( _
"[CONNECTION1].[UWY].[UWY]").ClearAllFilters
ActiveSheet.PivotTables("PivotTable1").PivotFields ( _
"[CONNECTION1].[UWY].[UWY]").CurrentPageName = _
"[CONNECTION1].[UWY].&[z]"
End Sub

However, I get an error. I tried many combinatios but I could not solve the problem. Thanks a lot.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default pivot table macro with a filtering variable

11 Eylül 2014 Perşembe 19:48:48 UTC+3 tarihinde isabelle yazdı:
hi,



may be:



"[CONNECTION1].[UWY].&[" & z & "]"



isabelle



Le 2014-09-11 12:42, oercim a �crit :

I have a problem. I will be very glad for any help.




I have a pilot table where tthe data source is obtained from an out source named "CONNECTION1". The below code is obtained by macro saving. It works fine.






Sub Macro1()


ActiveSheet.PivotTables("PivotTable1").PivotFields ( _


"[CONNECTION1].[UWY].[UWY]").ClearAllFilters


ActiveSheet.PivotTables("PivotTable1").PivotFields ( _


"[CONNECTION1].[UWY].[UWY]").CurrentPageName = _


"[CONNECTION1].[UWY].&[2012]"


End Sub




However, I want to define a "z"" variable which will be declared for filtering "year". The updated code is:




Sub Macro1()


z=2012


ActiveSheet.PivotTables("PivotTable1").PivotFields ( _


"[CONNECTION1].[UWY].[UWY]").ClearAllFilters


ActiveSheet.PivotTables("PivotTable1").PivotFields ( _


"[CONNECTION1].[UWY].[UWY]").CurrentPageName = _


"[CONNECTION1].[UWY].&[z]"


End Sub




However, I get an error. I tried many combinatios but I could not solve the problem. Thanks a lot.




That didn't solve the problem isabelle. I can't solve this problem. There must be an a solution
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default pivot table macro with a filtering variable

have you declared the variable x As Integer ?
Dim x As Integer

isabelle

Le 2014-09-15 13:21, oercim a écrit :

That didn't solve the problem isabelle. I can't solve this problem. There must be an a solution

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
Pivot Table Filtering - Macro kelly gardner Excel Programming 3 April 14th 10 04:23 PM
pivot table variable range within a macro Alberto Ast[_2_] Excel Programming 8 September 23rd 09 02:11 AM
Macro on filtering pivot table (pivot fields) = debug markx Excel Programming 2 May 28th 08 09:32 AM
variable last cell in pivot table macro Alan P Excel Programming 3 December 8th 05 04:09 PM
selecting variable rows in a macro that creates a pivot table amarch00 Excel Programming 1 May 12th 05 03:43 PM


All times are GMT +1. The time now is 10:58 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"