This is the challenge I'm facing:
I want to create macro's which are intended to autofilter data in a sheet. However, if new columns get insterted or re-arranged in the sheet (it's a living file), all macro's need to be changed again since the columns get shifted and so does the FIELD:= value of the Autofilter command.
I want to keep the macro's flexible by making the Autofilter use the Range name, as you can define by INSERT > NAME > DEFINE, and not having the command using the FIELD:=1 for column A, etc...
Current Example (filter col B on YES)
Selection.AutoFilter Field:=2, Criteria1:="YES"
Desired Example (filter name defined Range on YES)
Selection.AutoFilter Field:=RANGENAME, Criteria1:="YES"
With the RANGENAME I want to use the name of a defined range, which is flexible.
Any help is really aprreciated!
Thanks,
BA
I want to create macro's which are intended to autofilter data in a sheet. However, if new columns get insterted or re-arranged in the sheet (it's a living file), all macro's need to be changed again since the columns get shifted and so does the FIELD:= value of the Autofilter command.
I want to keep the macro's flexible by making the Autofilter use the Range name, as you can define by INSERT > NAME > DEFINE, and not having the command using the FIELD:=1 for column A, etc...
Current Example (filter col B on YES)
Selection.AutoFilter Field:=2, Criteria1:="YES"
Desired Example (filter name defined Range on YES)
Selection.AutoFilter Field:=RANGENAME, Criteria1:="YES"
With the RANGENAME I want to use the name of a defined range, which is flexible.
Any help is really aprreciated!
Thanks,
BA