Auto filter macro

  • Thread starter Thread starter Ali
  • Start date Start date
A

Ali

I will like to crete a macro that will select the 2nd
column of the filter to apply even if I add more columns
later on. So if I add more columns the autfilter will
select the second column. Any ideas?

Thanks again.
 
Field:=2 selects the second column in the autofilter range. Adding
columns to the left should have no effect.
 
My bad. I actually want that particular field no matter
what column it is in. So if I add another column it will
still point to that particula field

thanks again.
 
If the header for that column is Cost (as an example), then
Dim res as Variant
res = application.Match("Cost",Range("A1:IV1")
if not iserror(res) then
Range("A1").Autofilter Field:=res, . . .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top