Conditionally delete entire row if cell value in column B is not starting with word "Transfer"

primala

New Member
Joined
May 31, 2012
Messages
39
Hi,

How to conditionally delete entire row if cell value in Column B is not starting with word "Transfer", regarding uppercase, lowercase or proper. Starting from row # 2?

The number of row reaching 20,000 lines in maximum.

Thanks in advance
 

Some videos you may like

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,199
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
See if this works (untested) on a copy of your sheet.
Code:
Sub DeleteIfNotTransfer()
Dim lR As Long, R As Range, vA As Variant, dRws As Range, i As Long
lR = Range("B" & Rows.Count).End(xlUp).Row
Set R = Range("B2:B" & lR)
vA = R.Value
For i = LBound(vA, 1) To UBound(vA, 1)
    If Not InStr(1, UCase(vA(i, 1)), "TRANSFER") = 1 Then
        If Not dRws Is Nothing Then
            Set dRws = Union(dRws, R.Cells(i))
        Else
            Set dRws = R.Cells(i)
        End If
    End If
Next i
Application.ScreenUpdating = False
If Not dRws Is Nothing Then dRws.EntireRow.Delete
Application.ScreenUpdating = True
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,108,810
Messages
5,525,017
Members
409,615
Latest member
papaluigi94

This Week's Hot Topics

Top