Sunday, January 17, 2016

How to autofilter multiple values in Excel based on a range using a VBA macro

The autofilter of Excel is very powerful, however when you want to filter multiple items at once you'll have to select each ones individually:



This macro below will filter the first column of the database sheet based on a user range in sheet "Filter range". 


Sub filter_range()
Sheets("database").Range("$A$2:$B$2").AutoFilter Field:=1, Criteria1:=Application.Transpose(Sheets("Filter range").Range("A2:A8")), Operator:=xlFilterValues

End Sub





Created by DoMyExcel.com © | Excel & VBA Consulting | Customized Excel Solutions starting at 29 USD
Services provided to Individuals and Businesses | Free Quote: DoMyExcel@gmail.com
 EXCEL Consulting - FREE Estimate

No comments:

Post a Comment