Filtering Table based on Column Header

Yorke

New Member
Joined
Nov 29, 2021
Messages
19
Office Version
  1. 365
Platform
  1. Windows
Hi all,

Is it possible to filter a table based on the column header? All I can find is based on Field position (i.e. column number 23), but my column is not in a set position. I've seen a method which calculates the column position but this involves selecting where the table will be, and this is not set either (sorry!! It's not my file...)

The table is called "ZVA", in Worksheet 'Data', Table Header is 'Div', Filter on 'NS'

Thanks in advance :)

P.s. This is my current method which doesn't always work...
OpenBook.Worksheets("Data").ListObjects("ZVA").Range.AutoFilter Field:=23, Criteria1 :=Array("NS"), Operator:=xlFilterValues
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
How about
VBA Code:
   With OpenBook.Worksheets("Data").ListObjects("ZVA")
      .Range.AutoFilter Field:=.ListColumns("Div").Index, Criteria1:="NS"
   End With
 
Upvote 0
Solution
Brilliant, thank-you!

Just an add-on, how would I modify this code to filter this column to show "NS" and "SS"? In my previous method I was able to use:
Criteria1 :=Array("NS", "SS")

For future use, should this be a new thread?
 
Upvote 0
How about
VBA Code:
   With OpenBook.Worksheets("Data").ListObjects("ZVA")
      .Range.AutoFilter .ListColumns("Div").Index, Array("NS", "SS"), xlFilterValues
   End With
 
Upvote 0

Forum statistics

Threads
1,214,782
Messages
6,121,532
Members
449,037
Latest member
tmmotairi

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