cesnaplane
New Member
- Joined
- Jun 1, 2012
- Messages
- 1
Hi everybody,
I need to delete all the rows where values in column M does not match the criteria (cell from another sheet).
However this macro does delete all the rows, including ones that matches the criterion. Otherwise, if I use the code .AutoFilter 1,
it works properly and detele the rows that matches the criterion.
The rows contain strings with values "57.1" , "57.2", etc. (I use comma for decimical point instead of dot).
I need to delete all the rows where values in column M does not match the criteria (cell from another sheet).
Code:
Sub Deletetherow()
'
With ActiveSheet
.AutoFilterMode = False
With Range("M1", Range("M" & Rows.Count).End(xlUp))
.AutoFilter 1, Criteria1:="<>" & CStr(Sheets("Criteria").Range("$B$6"))
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
End With
End Sub
However this macro does delete all the rows, including ones that matches the criterion. Otherwise, if I use the code .AutoFilter 1,
Code:
Criteria1:=CStr(Sheets("Criteria").Range("$B$6"))
The rows contain strings with values "57.1" , "57.2", etc. (I use comma for decimical point instead of dot).