Delete rows that don't meet criteria

redspanna

Well-known Member
Joined
Jul 27, 2005
Messages
1,577
Office Version
  1. 365
Platform
  1. Windows
Hi all

Very simple question, but unsure of code...

look down column B of shee1 and delete any ROW that DOESN'T contain the content T5

many thanks
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Oeldere

Well-known Member
Joined
Dec 29, 2011
Messages
2,213
Use a filter on column B and select everything (except T5).

After that delete all rows.
 
Upvote 0

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try

Code:
Sub ColB()
Dim LR As Long, i As Long
With Sheets("Sheet1")
    LR = .Range("B" & Rows.Count).End(xlUp).Row
    For i = LR To 1 Step -1
        If .Range("B" & i).Value <> "T5" Then .Rows(i).Delete
    Next i
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,191,694
Messages
5,988,141
Members
440,129
Latest member
bianca88

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