K
ksnapp
Here is the code:
Sub Delete_Pork_in_string() ' deltes rows with reserve in column 3
Application.ScreenUpdating = False
Const cColumn = 2, cSearch = "PORK"
Dim I As Long, lngLastRow As Long
With ActiveSheet
lngLastRow = .Cells(Rows.Count, cColumn).End(xlUp).Row
For I = lngLastRow To 1 Step -1
If InStr(1, .Cells(I, cColumn).Value, cSearch) > 0 Then
If Not IsEmpty(Cells(I, "A")) Then
Cells(I + 1, "A").Value = Cells(I, "A").Value
End If
Rows(I).Delete xlShiftUp
End If
Next
End With
Application.ScreenUpdating = True
End SuB
the problem I'm having is that when it deletes a row that meets th
criteria it goes to next cell, which means that it skips one.
If i have a bunch of these cells that meet the criteria in a contigou
range down the column I only get rid of 1/2 of em.
any way to fix this or make a whole sub repeat itself a number o
times
Sub Delete_Pork_in_string() ' deltes rows with reserve in column 3
Application.ScreenUpdating = False
Const cColumn = 2, cSearch = "PORK"
Dim I As Long, lngLastRow As Long
With ActiveSheet
lngLastRow = .Cells(Rows.Count, cColumn).End(xlUp).Row
For I = lngLastRow To 1 Step -1
If InStr(1, .Cells(I, cColumn).Value, cSearch) > 0 Then
If Not IsEmpty(Cells(I, "A")) Then
Cells(I + 1, "A").Value = Cells(I, "A").Value
End If
Rows(I).Delete xlShiftUp
End If
Next
End With
Application.ScreenUpdating = True
End SuB
the problem I'm having is that when it deletes a row that meets th
criteria it goes to next cell, which means that it skips one.
If i have a bunch of these cells that meet the criteria in a contigou
range down the column I only get rid of 1/2 of em.
any way to fix this or make a whole sub repeat itself a number o
times