How to write an Excel VBA filter code for a single column, with multiple criteria. eg: Area Code - 245, 266, 330, 448, 1110 I would like the code to work even when one area code is missing, I must be able to filter the others without an error.
I tried if elseif, but was not able to find the solution. The auto filter works only if all the area codes are there in the spreadsheet. If a single area code is missing, the VBA throws an error.
Use Array()
in the criteria.
For example, Sheets(2).UsedRange.autofilter Field:=8, Criteria1:=Array("Goods", "Services"), VisibleDropDown:=True, Operator:=xlFilterValues
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.