VBA Filter

Confidentjohn

Board Regular
Joined
Mar 3, 2009
Messages
73
Hi

I have a macro setup in Excel that filters a data set.

The filter part looks like

Code:
ActiveSheet.PivotTables("cohortCLVTwoYear").CubeFields(17).EnableMultiplePageItems = _
        True
    ActiveSheet.PivotTables("cohortCLVTwoYear").PivotFields( _
        "[data1].[CUST_COMBINEDmonthsFromOrder].[CUST_COMBINEDmonthsFromOrder]"). _
        VisibleItemsList = Array( _
        "[data1].[CUST_COMBINEDmonthsFromOrder].&[01-03_Months]", _
        "[data1].[CUST_COMBINEDmonthsFromOrder].&[04-06_Months]", _
        "[data1].[CUST_COMBINEDmonthsFromOrder].&[07-09_Months]", _
        "[data1].[CUST_COMBINEDmonthsFromOrder].&[10-12_Months]", _
        "[data1].[CUST_COMBINEDmonthsFromOrder].&[13-18_Months]", _
        "[data1].[CUST_COMBINEDmonthsFromOrder].&[19-24_Months]")

Some of the data sets i have might not have some of the later fields.

Is there a way to program the filter to try the above, then if an error try

Code:
ActiveSheet.PivotTables("cohortCLVTwoYear").CubeFields(17).EnableMultiplePageItems = _
        True
    ActiveSheet.PivotTables("cohortCLVTwoYear").PivotFields( _
        "[data1].[CUST_COMBINEDmonthsFromOrder].[CUST_COMBINEDmonthsFromOrder]"). _
        VisibleItemsList = Array( _
        "[data1].[CUST_COMBINEDmonthsFromOrder].&[01-03_Months]", _
        "[data1].[CUST_COMBINEDmonthsFromOrder].&[04-06_Months]", _
        "[data1].[CUST_COMBINEDmonthsFromOrder].&[07-09_Months]", _
        "[data1].[CUST_COMBINEDmonthsFromOrder].&[10-12_Months]", _
        "[data1].[CUST_COMBINEDmonthsFromOrder].&[13-18_Months]")

again if that errors, try

Code:
ActiveSheet.PivotTables("cohortCLVTwoYear").CubeFields(17).EnableMultiplePageItems = _
        True
    ActiveSheet.PivotTables("cohortCLVTwoYear").PivotFields( _
        "[data1].[CUST_COMBINEDmonthsFromOrder].[CUST_COMBINEDmonthsFromOrder]"). _
        VisibleItemsList = Array( _
        "[data1].[CUST_COMBINEDmonthsFromOrder].&[01-03_Months]", _
        "[data1].[CUST_COMBINEDmonthsFromOrder].&[04-06_Months]", _
        "[data1].[CUST_COMBINEDmonthsFromOrder].&[07-09_Months]", _
        "[data1].[CUST_COMBINEDmonthsFromOrder].&[10-12_Months]")

On until the last item remains

Hope someone can help

Cheers

John
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,224,041
Messages
6,176,032
Members
452,697
Latest member
CuriousSpreadsheet

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top