Auto update a filter

jwgreen1986

Board Regular
Joined
Mar 8, 2019
Messages
64
i currently have a league table on a spreadsheet. a drop down lets you change certain things that will show in the league table (sales type, month etc)
the league table is working fine and automatically refreshes when the drop downs are changed. I then have a filter just to the right of the league tables (that i will hide) which puts a 1 in for valid sales based on the drop downs and a 0 for invalid.

the issue i am having is getting this filter to automatically apply when the drop downs are applied. with each option on the drop down the amount of people in the league table could change. so if i have one of the drop downs selected that shows 50 people, when i change the drop down to another option that only shows 30 people i am left with 20 blank cells in the league table. similarly if i do it the opposite way it will only show the first 30 people and the other 20 will remain hidden unless i manually apply the filter.

Is there a way that i can have this filter automatically update when a drop down option is changed?
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
up date on this, i have been given VBA codes to put in but these then mess around with the drop downs. so i have used the below, but when i then change the drop down it doesnt update the table with the data i need.

<code class="vb keyword" style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">Private</code> <code class="vb keyword" style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">Sub</code> <code class="vb plain" style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">Worksheet_Change(</code><code class="vb keyword" style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">ByVal</code> <code class="vb plain" style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">Target </code><code class="vb keyword" style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">As</code> <code class="vb plain" style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">Range)</code>
<code class="vb spaces" style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;"> </code><code class="vb plain" style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">Sheets(</code><code class="vb string" style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">"Sheet1"</code><code class="vb plain" style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">).AutoFilter.ApplyFilter</code>

<code class="vb keyword" style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">End</code> <code class="vb keyword" style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">Sub</code>
 
Upvote 0

Forum statistics

Threads
1,223,714
Messages
6,174,044
Members
452,542
Latest member
Bricklin

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