AutoFilter Field # - How do numeric designations work?

hip2b2

Board Regular
Joined
May 5, 2003
Messages
117
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
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,545
Office Version
  1. 365
Platform
  1. Windows
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
 
Solution

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

hip2b2

Board Regular
Joined
May 5, 2003
Messages
117
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
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,545
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,515
Messages
5,636,790
Members
416,941
Latest member
shazzaxyz

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
Top