I’m editing a document with 2500 entries and need to apply an AutoFilter, and this is my first try at editing the macro code, please have patience.
I used record to create the macro, and when I went to edit parts of it I got “Compile error: Expected: expression” outside the portion of the code I edited. the ‘…’ is many more entries.
ActiveSheet.Range("$A$1:$C$2500").AutoFilter Field := 2, Criteria1 := Array( _
"#N/A","3K Technologies, LLC","ABN","Accenture","AIMCo",...,"ITAT Partners" _
,"IT-Beratung Gunnar Hofmann","John Hancock","John Hancock Financial Network", _
End Sub
Not all the entries are shown and all of the code above except “End Sub” is in red.
It seems that since I recorded the macro, as opposed to writing it, all the name values are being stored and causing a problem. How do I apply an auto filter to a large selection of cells in VBA? Are the existing company names causing an overflow?
Thank you in advance!
If you just want to APPLY an Autofilter you can just use:
All of the rest of your code is all of the settings you recorded like each check-box for each column.
If you’re trying to edit the default selection settings in that stuff after the filter is applied, which section are you having trouble with in particular?
One thing to note is that Excel’s VBA can only continue the same line of code down around 24 times with the
_symbol at the end. Excel will fail to record the filter’s checkbox selections if there are too many so you’ll have to code them in by hand if this is, in fact, the specific problem you are having then follow this setup: