I have a worksheet that I am using a macro with multiple Autofilter statements to select specific criteria as I create a summary report. One such statement I am using in the macro is:
My problem is if I add columns anywhere prior to column 31, my macro will return incorrect results...unless of course I appropriately update the "field: =nn" number to correct the offset.
Is there anyway to that I can modify the "field:=" parameter to make it update automatically?
I read an article that discussed a similar situation with VLOOKUP where the column index reference could automatically update.... that code looked like:
However I couldn't get the COLUMN function to work. Thanks for any help.
Code:
Selection.AutoFilter field:=31, Criteria1:="Y", Operator:=xlOr, Criteria2:="N"
My problem is if I add columns anywhere prior to column 31, my macro will return incorrect results...unless of course I appropriately update the "field: =nn" number to correct the offset.
Is there anyway to that I can modify the "field:=" parameter to make it update automatically?
I read an article that discussed a similar situation with VLOOKUP where the column index reference could automatically update.... that code looked like:
Code:
=VLOOKUP(C1,A1:B12,COLUMN(B)-COLUMN(A1)+1)
However I couldn't get the COLUMN function to work. Thanks for any help.