Delete rows which not equal to criteria.

googleelgoog

New Member
Joined
Mar 2, 2004
Messages
9
Hi all,

Is there short way (without loop) to delete rows which its cetain cells not equal to criteria?


Example
A
_______
AAA
AAA
BBB
CCCC
AAA


Delete all except "AAA"

Thanks in advance.
 

Some videos you may like

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

onlyadrafter

Well-known Member
Joined
Aug 19, 2003
Messages
5,703
Platform
  1. Windows
Hello,

Can you not sort the column and then delete all non AAA rows.

ALternatively,

Select all the cells ensuring a cell with AAA, select GOTO-->SPECIAL and select COLUMN DIFFERENCES, al non AAA cells will be highlighted, select EDIT-->DELETE and check ENTIRE ROW.

Alternativelty there is a VB way, but you didn't want this.
 

onlyadrafter

Well-known Member
Joined
Aug 19, 2003
Messages
5,703
Platform
  1. Windows
Hello,

Here is the VB Code

Code:
Sub LEAVE_AAA()
For MY_ROWS = Range("A65536").End(xlUp).Row To 1 Step -1
    If Range("A" & MY_ROWS).Value <> "AAA" Then
        Rows(MY_ROWS).Delete
    End If
Next MY_ROWS
End Sub

Are you OK with creating macros?
 

Watch MrExcel Video

Forum statistics

Threads
1,122,554
Messages
5,596,814
Members
414,104
Latest member
imamalidadashzada

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