How to automatically delete certain rows in Excel?

How can I delete entire rows in Excel that contain certain keywords?

  • For work, I am currently filtering through a long list of items, and I have been filtering them out by CTRL+F finding and replacing the keywords that indicate rows I don't want with a big XXXXXXXXXXXXXX, then going through and deleting those rows. But is there a way to just eliminate any row that contains certain keywords?

  • Answer:

    You can try running a macro. 1. Press Alt+F11 to open the visual basic editor 2. On the left side of the window is the project explorer, which lists the worksheets of your workbook. 3. Double click on the worksheet you want to delete the rows from. That will open the code editor. 4. Paste the following code in the code editor: Sub DeleteRows() Const StringToFind As String = "XXXXXXXXXXXXXX" Dim cell As Range For Each cell In Me.UsedRange.Cells If InStr(1, cell.Formula, StringToFind) > 0 Then Me.Rows(cell.Row).Delete Next cell End Sub 5. Replace XXXXXXXXXXXXXX with the actual keyword, keeping it in quotation marks. 6. Click anywhere on this code and press F5.

wing2871... at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

Are those keywords the only ones in their cell? How many different variations of cell are there containing the words? You should be able to sort them, then put the rows together and delete them. Hope that helps.

Diana B

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.