How to Remove Specific Words from Excel Cells Using VBA
Question details
The user needs to remove a predefined list of words from sentences in a specific column and output the cleaned text to another column.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Cleaning text data by removing multiple specific substrings or words listed in a separate named range from a large dataset.
- Observed behavior
- The user requires a dynamic, case-insensitive VBA solution to process tens of thousands of rows efficiently without manual editing.
Ensure you have backed up your Excel workbook before running VBA macros, and verify that your list of words to remove is correctly defined as a named range with one word per cell.
Use a VBA Macro for Case-Insensitive Bulk Word Removal
This method uses a VBA script to iterate through your sentences and replace any matching words from your named list, ensuring fast processing for large datasets.
Using a VBA macro is the most efficient way to clean large volumes of text data. By leveraging the Replace function along with vbTextCompare, the script easily ignores uppercase and lowercase differences.
This solution reads the words from a named range (e.g., 'Pickles') and processes the sentences from a source column (e.g., Column D), placing the output directly into a destination column (e.g., Column E).
Press ALT + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.
Click 'Insert' from the top menu and select 'Module' to create a new blank script window.
Write or paste a VBA script that loops through your source column and named range array. Make sure to use the syntax Replace(text_string, word_to_remove, "", , , vbTextCompare) to ensure the replacement is case-insensitive.
Close the VBA editor and return to your worksheet. Press ALT + F8, select your new macro, and click 'Run' to process the text.
Effortlessly Manage Data and Macros with WPS Spreadsheet
WPS Office provides robust support for VBA and Macros, allowing you to run complex data cleaning scripts, like removing specific words from cells, seamlessly and efficiently.
- 1. Open Your Dataset: Launch WPS Spreadsheet and open the workbook containing your text data.
- 2. Access the VBA Editor: Go to the 'Developer' tab on the ribbon and click 'VBA Editor'.
- 3. Insert the Script: Insert a new module and paste your text replacement VBA code.
- 4. Execute the Code: Run the macro to instantly clean your target cells and output the formatted text.

Frequently Asked Questions
Can I use a standard Excel formula instead of VBA to remove specific words?
Yes, you can use the SUBSTITUTE function. However, nesting multiple SUBSTITUTE functions for a large list of words can become highly complex and difficult to maintain. VBA is highly recommended for lists longer than 3-5 words.
How do I create a named range in Excel for my word list?
Select the cells containing the words you want to remove, click the Name Box located to the left of the formula bar, type your desired name (like 'Pickles'), and press Enter.
Why isn't my VBA code removing words regardless of uppercase or lowercase?
Ensure your VBA Replace function includes the 'vbTextCompare' argument. By default, VBA performs a binary comparison (vbBinaryCompare) which is strictly case-sensitive. Adding vbTextCompare makes it case-insensitive.
How do I ensure only exact word matches are removed, not partial words?
To prevent removing partial matches (e.g., removing 'cat' from 'category'), you need to modify your VBA script to check for word boundaries. This can be achieved by adding spaces around the search term in your code or by utilizing Regular Expressions (RegEx).




