Delete Rows in Excel if a Cell Contains Specific Content

If you’re working with Excel and need to clean up your dataset fast, deleting rows where a certain cell contains a specific word or value can save a lot of time. Also you can filter out zeros, remove blank rows, or remove spam entries. If your Excel Sheet has unwanted rows, you don’t have to scroll and delete them one by one.

This guide walks you through different ways to delete rows, with or without using formulas or code based on cell content.

Key Takeaways

Ways to delete rows with specific content:

➤ Using Excel Filter option.
➤ Using Find tool from the menu.
➤ Using Formula in the Helper column.
➤ Using VBA Editor.

Use Find Tool from Menu Bar Add-ins

Download Practice Workbook
1

Using Excel Filters to Delete Rows Based on a Specific Text

This method is best when you can easily filter out the rows you don’t want to include. It’s perfect for basic cleanups and visual control. It is not necessary to know any formulas and scripts. You can use Excel’s built-in filter tool to hide and delete.

We’ll use a simple exam attendance dataset to show each method in action. You’ll see how to clean up entries without harming the rest of the sheet. It is more helpful if you are new to using Excel.

Using Excel Filters to Delete Rows

Steps:

➤ Select the entire dataset.
➤ Go to the Data Tab > click Filter. Small drop-downs will appear in each header.

Using Excel Filters to Delete Rows

➤ Click the dropdown on column C that you want to filter.

Using Excel Filters to Delete Rows

➤ Uncheck everything and only select the value you want to delete, like “Absent”.

Using Excel Filters to Delete Rows

➤ Select all the filtered rows (row numbers will be blue).

Using Excel Filters to Delete Rows

➤ Right-click on the filtered row numbers > click Delete Row.

Using Excel Filters to Delete Rows

➤ Then go back to Data > Filter to remove the filter.

Using Excel Filters to Delete Rows

➤ This is the result.

Using Excel Filters to Delete Rows

Note:
Use this when the value is visible and doesn’t need a partial match.


2

Use Find Tool from Menu Bar Groups

This method works great for messy or inconsistent values where filtering won’t help. It finds any cell that contains part of the word, not just exact matches.

Steps:

➤ Select column C that you want to search in.

Use Find Tool from Menu Bar Add-ins

➤ Go to Home > FInd & Select > Find.

Use Find Tool from Menu Bar Add-ins

➤ Type the word you want to search for (e.g., “Absent”). Click Find All.

Use Find Tool from Menu Bar Add-ins

➤ Press  Ctrl  +  A Â in the results to select all found cells.

Use Find Tool from Menu Bar Add-ins

➤ Press  Esc  to close the Find Box.
➤ Right-click any selected cell > choose Delete.

Use Find Tool from Menu Bar Add-ins

➤ This will delete all rows containing the word “Absent” anywhere in column C.

Note:
This method finds cells that contain a string, even if it is part of a longer sentence.


3

Add a Helper Column and Find Rows to Delete

This is safer for large data or when conditions are complex. If you are not confident about deleting rows right away, or you want to flag rows before removing them, this method lets you mark them before removing them and delete later. You’ll use a formula to mark which rows to delete.

This approach gives you full control and avoids accidental deletions.

Steps:

➤ Insert a new column, column F, beside your data.
➤ In column F, use a formula like:

=IF(ISNUMBER(SEARCH(“Absent. C2”)), “Delete”, “ ”)

This looks inside cell C2. If it finds “Absent”, it returns “Delete”.

Add a Helper Column and Find Rows to Delete

➤ Drag the formula down the column.

Add a Helper Column and Find Rows to Delete

➤ Now filter helper column F for “Delete”.

Add a Helper Column and Find Rows to Delete

➤ Select rows 3,5, and 11 where the word “Delete” appears and delete them as before.

Add a Helper Column and Find Rows to Delete

➤ Remove the helper column, column F, when done.

Add a Helper Column and Find Rows to Delete

Note:
Use Search for partial matches and = for exact matches like
=IF(C2=" Absent", "Delete", " ")


4

Delete Rows Automatically Based on Specific Cell Content with VBA

For repetitive tasks, using a macro can save a lot of time. You can delete rows in one click based on what a cell contains.

Steps:

➤ Press  Alt  +  F11 Â to open the VBA editor.

Run a VBA Code to Delete Rows Automatically Based on Specific Cell Content

➤ Go to Insert > Module and paste this code:

Sub DeleteIfContains()
           Dim ws As Worksheet
           Set ws = ActiveSheet
           Dim i As Long
           Dim lastRow As Long
       lastRow = ws.Cells(ws.Rows.Count, “C”).End(xlUp).Row
      For i = lastRow To 2 Step -1 
            If Instr(ws.Cells(i,3).Value, “Absent”) > 0 Then
                 ws.Rows(i).Delete
            End If
     Next i
   End Sub

This checks Column C. If a cell contains “Absent”, it deletes that row.

Run a VBA Code to Delete Rows Automatically Based on Specific Cell Content

➤ Close the editor and click Run. All matching rows will be deleted automatically.

Run a VBA Code to Delete Rows Automatically Based on Specific Cell Content

Note:
Always save your file before using VBA, and test on a copy if unsure.

➤ Here is the result. You can remove the row for “Cheated” and “N/A” the same way.

Run a VBA Code to Delete Rows Automatically Based on Specific Cell Content


Frequently Asked Questions

Can I delete rows based on multiple values?

Yes, use OR logic in formulas or modify the VBA to include more conditions.

Will this delete formulas too?

Yes. If a row is deleted, everything in it including formulas will be gone.

Can I undo VBA deletions?

Only if you haven’t saved after running the macro. Press  Ctrl  +  Z  right after.

What happens to blank rows?

You can adapt the same methods to delete rows where a cell is blank using =ISBLANK() in formulas or modifying the VBA.


Wrapping Up

Deleting rows in Excel if a cell contains a specific value can be done in many ways from filters to formulas to VBA. Each method fits a different situation. If you want control and safety, use the helper column. For speed, go with filters. And if you’re automating tasks, VBA is the way to go.

Now your Excel Sheet is cleaner, lighter, and easier to read. Let us know which method worked best for you.

ExcelInsider Team
We will be happy to hear your thoughts

Leave a reply

Excel Insider
Logo