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

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,226,694
Messages
6,192,473
Members
453,726
Latest member
JoeH57

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