L
Lazer
Frank, thank you. I looked at the link you sent and modified it a
such:
'---------------------------------------------------------------------------
Sub DeleteRowsContaining(targetText As String, targetColumn As Long)
'---------------------------------------------------------------------------
' Function: Conditionally remove rows
' Synopsis: Calculates the number of rows
' Loops backwards through each row testing if same
' as previous
' Assumptions: The data is sorted, if not add sort to code
' Author: based on code by Bob Phillips, original version:
' http://www.xldynamic.com/source/xld.Deletingv1.html
' modified by Eliezer, 10/27/04
'---------------------------------------------------------------------------
Dim cRows As Long
Dim i As Long
'first, count the rows to operate on
cRows = Cells(Rows.Count, targetColumn).End(xlUp).Row
For i = cRows To 2 Step -1
'check if current row matches the "target text"
If InStr(6, (Cells(i, targetColumn).Value)) = "66" Then
Cells(i, targetColumn).EntireRow.Activate
'Cells(i, targetColumn).EntireRow.Delete
End If
Next i
End Sub
...but it doesn't seem to do anything with rows containin
"6400-66-0-000000" in column B.
Any ideas, please?
Thanks again!
Elieze
such:
'---------------------------------------------------------------------------
Sub DeleteRowsContaining(targetText As String, targetColumn As Long)
'---------------------------------------------------------------------------
' Function: Conditionally remove rows
' Synopsis: Calculates the number of rows
' Loops backwards through each row testing if same
' as previous
' Assumptions: The data is sorted, if not add sort to code
' Author: based on code by Bob Phillips, original version:
' http://www.xldynamic.com/source/xld.Deletingv1.html
' modified by Eliezer, 10/27/04
'---------------------------------------------------------------------------
Dim cRows As Long
Dim i As Long
'first, count the rows to operate on
cRows = Cells(Rows.Count, targetColumn).End(xlUp).Row
For i = cRows To 2 Step -1
'check if current row matches the "target text"
If InStr(6, (Cells(i, targetColumn).Value)) = "66" Then
Cells(i, targetColumn).EntireRow.Activate
'Cells(i, targetColumn).EntireRow.Delete
End If
Next i
End Sub
...but it doesn't seem to do anything with rows containin
"6400-66-0-000000" in column B.
Any ideas, please?
Thanks again!
Elieze