PDA

View Full Version : Autofilter Field



bradh_nz
07-30-2007, 07:51 AM
Is it possible to make the below criteria for a filter dynamic by making:

This
Selection.AutoFilter Field:=17

Becoming
Selection.AutoFilter Field:="The Column Name"

Thanks
Brad

rory
07-30-2007, 07:58 AM
You can use something like:
selection.autofilter field:=application.match("column name", selection.rows(1), 0)

Regards,
Rory

bradh_nz
07-30-2007, 08:11 AM
Fantastic, thanks

rory
07-30-2007, 08:14 AM
No problem. It's probably safer, unless you can guarantee the column name exists, to store the result of the Application.Match in a variant variable and check it using IsError just to be sure there was a match.
Regards,
Rory