vba code to filter a chart

FuNeS13

Board Regular
Joined
Oct 25, 2016
Messages
161
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. Mobile
  3. Web
So I have this loop working to filter a pivot table, but now I need to filter a couple of charts as well:


VBA Code:
Dim pf As PivotField

Set pf = ActiveSheet.PivotTables("TOP10").PivotFields("Buyer")

    With pf
        .ClearManualFilter
        .EnableMultiplePageItems = True
        For i = LBound(pvtFilter) To UBound(pvtFilter)
            On Error Resume Next
            .PivotItems(pvtFilter(i)).Visible = False
        Next i
    End With

I need a similar code but with a chart, when I record the process I get this code but I don't know how to modify it to work as I try:

VBA Code:
    ActiveSheet.ChartObjects("Chart 2").Activate
    ActiveChart.FullSeriesCollection(1).IsFiltered = True
    ActiveChart.FullSeriesCollection(2).IsFiltered = False

My logic would be something like:


VBA Code:
Dim ChrtObj As ChartObject
Dim value As String
value = "9"

Set ChrtObj = ActiveSheet.ChartObjects("Chart 2")



    With ChrtObj
        For j = 1 to 10 '(this is the amount of items in the filter, 10)
            ActiveChart.FullSeriesCollection(chrtobject).IsFiltered = True
        Next j
        
        .ActiveChart.FullSeriesCollection(value).IsFiltered = False
    End With

but i'm completily lost... (yeah my code doesn't work...)....................... any help will be greatly appreciated.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
I still need help with this... anyone?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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