Delete entire rows based on the first column?

afs24

Board Regular
Joined
Sep 26, 2002
Messages
237
How can I delete rows with a specific abbreviation. I have thousands of rowns with different information in each colum. The first column of each row has a certain abbreviation (SF, SP, FP, etc....). How do I delete the entire rows that have SP in the first column.


SP 10 asdf
SP 3 fgeg
FP 8 lpoj

In this example I want the first two rows completly delted?

Thanks.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi afs24,

If your data if of the text variety, then this SQL should do what you need:

DELETE Tbl1.Enter_Field, Left([enter_field],2) AS left2
FROM Tbl1
WHERE (((Left([enter_field],2))="SP"));

To use this, create a new query in design view. Click on the little downward-pointing arrow on the button you click to switch between design and datasheet view, and selecing SQL. Then insert the above phrase.

All I did to do this, was create a new query in design view, insert a table with data like yours, and then wrote this expression where you would normally have the field name:

left2: Left([enter_field],2)

left2 is an arbitrary name for the column.

Then set the criteria in this field to "SP", or whatever you want to get.

Now select 'query' on the main toolbar, and change the query type to a delete table (you'll have to extend the window, most likely).

Now, when you're ready, click on the little exclamation point, or double click on the query's icon when the query is closed, and it will run, seleting the records for wich you specified criteria.

HTH,
 
Upvote 0

Forum statistics

Threads
1,221,567
Messages
6,160,540
Members
451,655
Latest member
rugubara

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
Back
Top