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
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,932
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,827
Messages
5,855,878
Members
431,771
Latest member
CoryMelth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top