Pivot Table filter changes when source data is updated

giaudi

New Member
Joined
Jul 29, 2010
Messages
8
Hi guys,
I'm having a weird issue with my beloved pivot tables. In my spreadsheet I have a pivot table which looks up aroud 500 rows of data and that is filtered on a few defined account numbers. I am refreshing the source data daily, and every day I find myself checking that the pivot is still filtering on the correct accounts. Every time I update the data (through a macro) and refresh all pivot tables (through a macro), there are a few more accounts that get added to the filter.
Do you have any idea of how I can lock the filters in my pivot table?

Thanks in advance and hapy christmas

G
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hi Giaudi,

Doing a little testing, it looks like xl2007 retains selected filtered items, and doesn't select newly added items if you merely refresh and/or change the data source.

Your macros might be clearing the filter and then reseting it. Can you post the macros you are using to update the data and refresh the pivot tables? There might be a step that is resetting the filters that can simply be removed.
 
Last edited:
Upvote 0
One way. Add another table to the source data, listing just the particular accounts you want to see. Then set up the dataset with SQL like
Code:
SELECT PT.*
FROM PresentTable PT, NewTableOfWantedAccountCodes NT
WHERE PT.AccountCode = NT.AccountCode

Then no filters are needed in the pivot table as the data source for the pivot table will contain only the wanted accounts.
 
Upvote 0
Thanks guys!

To import new data, the macro opens the daily file and...

Range("L2").Select
Range(Selection, Selection.End(xlDown)).Copy
Range("M2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("M2:M3000").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range( _
"N2"), Unique:=True


and to refresh pivot tables..

ThisWorkbook.RefreshAll


Fazza's solution seems a bit out of range (no SQL skills), but I will have a play around and see if I work something out

G
 
Upvote 0
Fazza- Thanks for sharing that approach. I had thought SQL was only used for database application sources like Access; but your comments led me to learn it can be useful for queries of Excel data sources too.

Giaudi- When I use your code with some sample data, my Pivot Table still retains it's filters. I'm assuming that Row 2 is a header row for your Pivot Table data; but it isn't clear to me which Column(s) your Pivot Table is using and which Field is the filter that isn't retaining it's selection. That makes it more difficult to try to replicate the problem you describe.

I'd be glad to look at your workbook if you can post a link, or exchange through a PM.
 
Upvote 0

Forum statistics

Threads
1,214,782
Messages
6,121,532
Members
449,037
Latest member
tmmotairi

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