Forum Discussion
Filter Non-Adjacent Columns
- Jul 31, 2022
Let's say the table is named Table1.
Press Alt+F11 to activate the Visual Basic Editor.
Press Ctrl+G to activate the Immediate window in the Visual Basic Editor.
Type or copy/paste the following line:
ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=2, VisibleDropdown:=False
With the insertion point anywhere in that line, press Enter.
Hi dscheikey ,
Apologies for the typo, I was asking about the "Filter" function found in the "Data" tab.
I am attempting to apply the drop-down filter menus to two non-adjacent columns in the same table.
Please see the below example of what i am trying to achieve.
Let's say the table is named Table1.
Press Alt+F11 to activate the Visual Basic Editor.
Press Ctrl+G to activate the Immediate window in the Visual Basic Editor.
Type or copy/paste the following line:
ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=2, VisibleDropdown:=False
With the insertion point anywhere in that line, press Enter.
- Dean_T-BJul 31, 2022Copper Contributor
Thanks HansVogelaar, that worked perfectly. Is there a way to do this if my data is not in a table? I have a much bigger spreadsheet I'd like to do this for as well.
- HansVogelaarJul 31, 2022MVP
Yes: instead of ActiveSheet.ListObjects("Table1").Range specify the range it applies to, for example Range("A1:T100")
- Dean_T-BJul 31, 2022Copper Contributor
That's great HansVogelaar, you've been a massive help!!
One final thing, is it possible to filter by headings?
Please see below as an example, I'm only wanting the letters "A" and "B" to show up on the drop-down menu, but I'd like all of the information in its category to still show. I'm hoping there's a way to do this without the visual matrix.