Excel VBA Slicer - Ignoring a Value if Not Found in Array

jangovin

New Member
Joined
May 5, 2021
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
I have a pivot dashboard that is projecting Due/Overdue status for 3 tasks, measured in the following values:
  • Overdue >15 Months
  • Overdue 14-15 Months
  • Overdue 12-14 Months
  • Due in 1-30 days
  • Due in 31-90 days
  • Record Up to Date
The Pilot tables are linked to 3 slicers (named - MDT, BRP, BCE), which allows a user to select specific status, or combination of status, for each task, which then gets reflected into the dashboard.

In order to make the process easier for the user, I was looking to introduce a button to set all 3 slicers to show anything "overdue" only, the code for which is below. The code runs perfectly when all 3 "overdue" status appears for each of the 3 slicers.

The problem I have is when any of these "overdue" status is missing from the slicer, resulting in "Runtime Error 1004: Item could not be found in OLAP cube".

I am quite new to VBA, and having trouble setting the code to identify and filter any combination of "overdue" values. Would be glad to have some assistance to help develop the correct code that achieves this.

VBA Code:
ActiveWorkbook.SlicerCaches("Slicer_MDT").VisibleSlicerItemsList _
    = Array( _
    "[Range].[MDT].&[Overdue >15 Months]", _
    "[Range].[MDT].&[Overdue 14-15 Months]", _
    "[Range].[MDT].&[Overdue 12-14 Months]")
ActiveWorkbook.SlicerCaches("Slicer_BRP").VisibleSlicerItemsList _
    = Array( _
    "[Range].[BRP].&[Overdue >15 Months]", _
    "[Range].[BRP].&[Overdue 14-15 Months]", _
    "[Range].[BRP].&[Overdue 12-14 Months]")
ActiveWorkbook.SlicerCaches("Slicer_BCE").VisibleSlicerItemsList _
    = Array( _
    "[Range].[BCE].&[Overdue >15 Months]", _
    "[Range].[BCE].&[Overdue 14-15 Months]", _
    "[Range].[BCE].&[Overdue 12-14 Months]")
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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