Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default assign filter inside macro

hi there,

I am not a VBA user and got code from a book to generate a pivottable from a
macro. Now the problem is I want to assing the filter on column header '
Period' in the code and dont know which property to change. following is the
code of the macro

Sub CreatePivotFields()

ActiveSheet.PivotTableWizard _
SourceType:=xlDatabase, _
SourceData:="'Source'!R1C1:R73C7", _
TableName:="Sales&Trans"

With ActiveSheet.PivotTables("Sales&Trans")
..PivotFields("Year").Orientation = xlPageField
..PivotFields("Year").Position = 1
..
..
..PivotFields("Period").Orientation = xlColumnField

at this point i want to assign a filter to 'Period' so it only display
period 'one' items in the pivot.

thanks,


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default assign filter inside macro

Try
I don't know how many items you have, you may have to adjust.

..PivotFields("Period").Orientation = xlColumnField
With ActiveSheet.PivotTables("Sales&Trans").PivotFields ("Period")
.PivotItems("1").Visible = True
.PivotItems("2").Visible = False
.PivotItems("3").Visible = False
.PivotItems("5").Visible = False
End With
Skinman

"Atiq" wrote in message
...
hi there,

I am not a VBA user and got code from a book to generate a pivottable from
a
macro. Now the problem is I want to assing the filter on column header '
Period' in the code and dont know which property to change. following
is the
code of the macro

Sub CreatePivotFields()

ActiveSheet.PivotTableWizard _
SourceType:=xlDatabase, _
SourceData:="'Source'!R1C1:R73C7", _
TableName:="Sales&Trans"

With ActiveSheet.PivotTables("Sales&Trans")
.PivotFields("Year").Orientation = xlPageField
.PivotFields("Year").Position = 1
.
.
.PivotFields("Period").Orientation = xlColumnField

at this point i want to assign a filter to 'Period' so it only display
period 'one' items in the pivot.

thanks,



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default assign filter inside macro

thanks Skinman, it worked.

now another question :), is it possible to give excluesive code, i mean can
i put code to say that show "1" and hide all others without needing to know
the complete list of values in that pivot item.

thanks again.

"Skinman" wrote:

Try
I don't know how many items you have, you may have to adjust.

..PivotFields("Period").Orientation = xlColumnField
With ActiveSheet.PivotTables("Sales&Trans").PivotFields ("Period")
.PivotItems("1").Visible = True
.PivotItems("2").Visible = False
.PivotItems("3").Visible = False
.PivotItems("5").Visible = False
End With
Skinman

"Atiq" wrote in message
...
hi there,

I am not a VBA user and got code from a book to generate a pivottable from
a
macro. Now the problem is I want to assing the filter on column header '
Period' in the code and donĂ¢‚¬„¢t know which property to change. following
is the
code of the macro

Sub CreatePivotFields()

ActiveSheet.PivotTableWizard _
SourceType:=xlDatabase, _
SourceData:="'Source'!R1C1:R73C7", _
TableName:="Sales&Trans"

With ActiveSheet.PivotTables("Sales&Trans")
.PivotFields("Year").Orientation = xlPageField
.PivotFields("Year").Position = 1
.
.
.PivotFields("Period").Orientation = xlColumnField

at this point i want to assign a filter to 'Period' so it only display
period 'one' items in the pivot.

thanks,




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
Is it possible to filter the data inside the series command? Khoshravan Charts and Charting in Excel 2 September 4th 07 01:18 PM
Event Macro running another macro inside K1KKKA Excel Discussion (Misc queries) 1 December 20th 06 08:21 PM
How to assign same code inside Option button code space ?? furbiuzzu Excel Programming 1 November 21st 06 02:36 PM
using a cell value to control a counter inside a macro and displaying macro value ocset Excel Worksheet Functions 1 September 10th 06 05:32 AM
Need macro to filter, create tab on filter and copy/paste Jen[_11_] Excel Programming 1 May 2nd 06 04:45 PM


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