VBA - setting autofilter options

Puppies72

Board Regular
Joined
Mar 29, 2010
Messages
211
Hi all,

I have a sheet that is autofiltered and want to write into a macro certain combinations of autofilter - how can I do this?

For example - column A:AS is autofiltered and the dropdown for column K shows the numbers 1 through 16 - I want to be able to automatically set that autofilter to the value shown in A1 on a different sheet.

Can someone show me that example and I can work the rest out from it

many thanks in advance
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Try recording a macro and editing the code to use the criteria value from the other sheet. The result should be something like:

Selection.AutoFilter Field:=11, Criteria1:=Sheets("Other_Sheet").Range("A1").Value
 
Upvote 0
Great stuff thank you John - already had the macro recorded but didn't know how to make it set the value to that in another sheet!

Ended up with

Code:
Sheets("Terrain").Select
    ActiveSheet.Range("$A$3:$AS$10003").AutoFilter Field:=11, Criteria1:=Sheets("Ships").Range("A1").Value
    ActiveSheet.Range("$A$3:$AS$10003").AutoFilter Field:=15, Criteria1:="<>"
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,738
Members
452,940
Latest member
Lawrenceiow

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