Can't find selected multiple values in report filter

bb_89_gd

New Member
Joined
Dec 15, 2016
Messages
1
Hi. First time poster.

I have a pivot table named summaryTable2 generated by VBA and have created a report filter via VBA for the field "Date". The filter was generated with the code

With ActiveSheet.PivotTables("summaryTable2").PivotFields("Date")
.Orientation = xlPageField
End With

I have been looking around forums etc trying to find a way to list out the selected values for the date filter. I have had no luck. Currently I am using the below code.


For Each date_filter In Worksheets("Running Totals").PivotTables("summaryTable2").PivotFields("Date").PivotItems

If date_filter.Visible = True Then

Cells(i, 3).Value = date_filter

i = i + 1

End If

Next date_filter


The code is running without error. However date_filter.visible always remains false, even when I select specific values in the drop down date filter. So nothing is listed in the chosen cells.

Some points to note.

The code works fine if date is chosen as a Row filter (it will list out the chosen values from the filter)

Date_filter is declared as a pivot item. If I put in the code date_filter.visible = true, the code will run but immediately after that line, date_filter.Visible reverts to False.

I have tried putting

ActiveSheet.PivotTables("summaryTable2").PivotCache.MissingItemsLimit = xlMissingItemsNone

At the start of the code and also tried refreshing the pivot tables. Nothing is working.

I've also tried changing 'PivotFields' to 'PageFields' in the For statement and it still doesn't work.

Any help would be much appreciated.

PS posting from mobile sorry if code isn't in right format.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Forum statistics

Threads
1,214,653
Messages
6,120,748
Members
448,989
Latest member
mariah3

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