AutoFilter Field # - How do numeric designations work?

hip2b2

Board Regular
Joined
May 5, 2003
Messages
135
Office Version
  1. 2019
Platform
  1. Windows
I am using the following code, works just fine. My question has to do with the field designation.

VBA Code:
 .AutoFilter Field:=11, Criteria1:="=Closed" & strName & "*", Operator:=xlAnd
 .Offset(1).Resize(.Rows.Count - 1).EntireRow.Delete
 .AutoFilter Field:=11

The field that contains the filter criteria is Col S. As S is not the 11th letter of the alphabet how does this work? I do note that Col S is the 11th Col in my spreadsheet that is populated with text, or am I drawing a false conclusion?

Is there any simple way to modify the code to relate to an absolute column designation?

Thanks

hip
 
Maybe
VBA Code:
Set h = Sheets("For XYZ")
If h.AutoFilterMode Then h.AutoFilterMode = False
lr = Columns("A:S").Find(What:="*", LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
With h.Range("A6:S" & lr)

.AutoFilter Field:=2, Criteria1:="=Open" & strName & "*", Operator:=xlAnd
.Offset(1).Resize(.Rows.Count - 1).EntireRow.Delete
.AutoFilter

.AutoFilter Field:=19, Criteria1:="=Closed" & strName & "*", Operator:=xlAnd
.Offset(1).Resize(.Rows.Count - 1).EntireRow.Delete
.AutoFilter
 
Upvote 0
Solution

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.
Maybe
VBA Code:
Set h = Sheets("For XYZ")
If h.AutoFilterMode Then h.AutoFilterMode = False
lr = Columns("A:S").Find(What:="*", LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
With h.Range("A6:S" & lr)

.AutoFilter Field:=2, Criteria1:="=Open" & strName & "*", Operator:=xlAnd
.Offset(1).Resize(.Rows.Count - 1).EntireRow.Delete
.AutoFilter

.AutoFilter Field:=19, Criteria1:="=Closed" & strName & "*", Operator:=xlAnd
.Offset(1).Resize(.Rows.Count - 1).EntireRow.Delete
.AutoFilter
Perfect!!!
Thank you so much for your help and patience.

hip
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,632
Messages
6,120,649
Members
448,975
Latest member
sweeberry

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