M
melara
Hi I need to delete all lines except those containing the Text NMI, FromDate>,
To Date>
Can someone tell me where I'm going wrong with this Macro when I run it, it
deletes all lines?
Public Sub DeleteNonSpecific Rows()
Dim rCell As Range
Dim rDelete As Range
For Each rCell In Range("A1:A" & _
Range("A" & Rows.Count).End(xlUp).Row)
With rCell
If Not (Text) = " FromDate>" Or _
(Text) = " ToDate>" Or _
UCase(.Text) = " NMI> ") Then
If rDelete Is Nothing Then
Set rDelete = .Cells
Else
Set rDelete = Union(rDelete, .Cells)
End If
End If
End With
Next rCell
If Not rDelete Is Nothing Then rDelete.EntireRow.Delete
End Sub
To Date>
Can someone tell me where I'm going wrong with this Macro when I run it, it
deletes all lines?
Public Sub DeleteNonSpecific Rows()
Dim rCell As Range
Dim rDelete As Range
For Each rCell In Range("A1:A" & _
Range("A" & Rows.Count).End(xlUp).Row)
With rCell
If Not (Text) = " FromDate>" Or _
(Text) = " ToDate>" Or _
UCase(.Text) = " NMI> ") Then
If rDelete Is Nothing Then
Set rDelete = .Cells
Else
Set rDelete = Union(rDelete, .Cells)
End If
End If
End With
Next rCell
If Not rDelete Is Nothing Then rDelete.EntireRow.Delete
End Sub