It's all perfect code finds the column name and filter's it correctly
But not sure as it also deletes the header on delete visible cells only more over it takes time to delete visible cells
any suggestion and modify the code thanks header starts from cell A7
But not sure as it also deletes the header on delete visible cells only more over it takes time to delete visible cells
any suggestion and modify the code thanks header starts from cell A7
VBA Code:
Sub autofiltering()
Dim col As String, cfind As Range
Dim coll As String, ccfind As Range
Sheets("Auduince Burn").Select
col = "Region"
With Worksheets("Auduince Burn")
With .Range("A7", .Cells(7, .Columns.Count).End(xlToLeft))
Set cfind = .Find(what:=col, LookIn:=xlValues, lookat:=xlWhole) '<-- look for the wanted column header
If Not cfind Is Nothing Then '<-- if the header has been found
.AutoFilter Field:=cfind.Column, Criteria1:="<>" & "WEST"
.Range("A7").Offset(1).SpecialCells(xlCellTypeVisible).EntireRow.Delete
' Keeping header it should delete only visible cells till the last record
End If
End With
.AutoFilterMode = False '<-- show all rows back and remove autofilter buttons
End With
End Sub