Remove row based on cell value
<p>The code is designed to remove the column headers (after importing several files) for the data. But I get error: "1004" Which is "Application-defined or object-defined error". I've referenced different solutions on SO but to no avail. </p>

<p>Before I run this code snippit I remove the blank rows and have included this to show what does work as well and might even hold the key. </p>

<pre><code>'Remove all rows with blanks first
Set wb = Workbooks(ThisWorkbook.Name)
'Remove blank rows based on if column 'B' is blank as a and B are filled when there is risk key showing
wb.Worksheets("BatchData").Activate
Columns("B:B").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
'Now to delete based on column headers!
Dim LastRow As Long
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
'Filter Column A and delete selection
'############# Error line below
ActiveSheet.Range("A1:" &amp; A &amp; ":" &amp; LastRow).AutoFilter Field:=2, Criteria1:= _
        "=Item", Operator:=xlOr, Criteria2:="="
Selection.EntireRow.Delete
</code></pre>

<p>EDIT:</p>

<p>Amended code, some tweaks as per comments and also I had field "2" referenced and was trying to use 'A' which is 1.</p>

<pre><code>Dim LastRow As Long
LastRow = wb.Worksheets("BatchData").Cells(Rows.Count, 1).End(xlUp).Row
'Filter Column A and delete selection
ActiveSheet.Range("A1:A" &amp; LastRow).AutoFilter Field:=1, Criteria1:= _
        "=Item", Operator:=xlOr, Criteria2:="="
</code></pre>

<p>ActiveSheet.Range("$A$1:$A$" &amp; LastRow).Offset(0, 0).SpecialCells _
    (xlCellTypeVisible).EntireRow.Delete</p>

<p>Last line edit based on; <a href="https://stackoverflow.com/questions/17194394/vba-how-to-delete-filtered-rows-in-excel">VBA: How to delete filtered rows in Excel?</a> but offset changed from 1,0 to 0,0</p>