Alvaroro84
Board Regular
- Joined
- May 13, 2022
- Messages
- 65
- Office Version
- 2016
- Platform
- Windows
Is it possible to create a macro that filters by using the headers name rather then the specific column? If so what would something like that look like?
Sub FileterByHeader()
vCHeader = Rows(1).Find("Header 2", , xlValues, xlWhole, , , True).Column
Range("A1:E5").AutoFilter vCHeader, "Some Text"
End Sub
Sub Fltr()
With ActiveSheet.ListObjects(1)
.Range.AutoFilter Field:=.ListColumns("Header 2").Index, Criteria1:="Some Text"
End With
End Sub
With ActiveSheet.Range("A1:E5")
.AutoFilter Application.Match("Header 2", .Rows(1), 0), "Some Text"
End With