Method 1: Using AutoFilter (Recommended)
This method allows you to instantly display only the rows that do not contain your text, which can then be deleted.
- Enable Filter: Select your header row and go to Data > AutoFilter (or press
Ctrl+Shift+L). - Filter for Text: Click the dropdown arrow in the column header that contains the text you are checking.
- Use Standard Filter: Select Standard Filter….
- Set Condition:
- Field Name: Select the column.
- Condition: Choose Does not contain.
- Value: Type the specific text you want to search for.
- Delete Rows: Select all the visible rows, right-click on the row numbers, and choose Delete Rows.
- Remove Filter: Go to Data > Remove Filter to show the remaining data.
Method 2: Formula to Flag Rows
If you prefer a formula approach to create a “helper” column, you can use IF with ISNUMBER and SEARCH (case-insensitive) to mark rows.
Assuming your data is in column A and you want to keep rows containing “Yes”:
- In a new column (e.g., B1), enter this formula:
=IF(ISNUMBER(SEARCH("Yes"; A1)); "Keep"; "Delete")
(Note: Use a comma,instead of a semicolon;if your locale settings require it). - Fill this formula down for all rows.
- Filter the helper column (B) to show only “Delete”.
- Delete those rows.
Method 3: “Find and Replace” (Alternative)
- Press
Ctrl+Fto open the Find and Replace dialog. - Type the text you want to keep.
- Click Find All.
- Invert the selection: Choose Edit > Select > Select All (this may not work in all versions, making Method 1 or 2 better), or simply use the Filter method (Method 1) as it is more reliable for inverting selections.
Wildcards: You can use * as a wildcard (e.g., *text*) in the Standard Filter.
Case Sensitivity: SEARCH is not case-sensitive; use FIND for case-sensitive searches.
Deleting Hidden Rows: After filtering, ensure you are only selecting and deleting visible rows.