VBA & Macro Problems

How to Ignore Excel Cells Containing Specific Text in VBA

Adam DavisAdam Davis Nov 3, 2026 868 views

Question details

The user needs a VBA routine to skip processing specific cells in a column when they contain an exact text string, such as 'REMARKS'.

How to Skip Cells Containing Specific Text in Excel VBA
Product
Excel
Device & OS
not provided
Scenario
Running a VBA macro that iterates through rows to append or modify data, but requires excluding rows where a specific column contains predefined text.
Observed behavior
The macro processes all rows by default, requiring conditional logic to bypass cells holding specific words so that only the relevant rows are updated.
Before you start

Before modifying your script, ensure you have enabled the Developer tab in your spreadsheet and saved a backup copy of your current VBA code.

Solution 1Recommended

Use an IF Condition with UCase and Trim to Skip Cells

Add a logical IF condition in your VBA loop to check the cell's value and bypass the execution logic if it matches your target text.

To effectively ignore cells with specific text, you can wrap your existing execution code inside an IF statement. By using the UCase and Trim functions, you ensure that accidental spaces or different capitalizations do not cause the macro to process the cell by mistake.

1
Open the VBA Editor

Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor in Excel.

2
Locate your macro loop

Find the section of your script where you are iterating through the rows. This is typically a 'For' loop using a variable like 'i'.

3
Insert the skip condition

Add an IF statement that checks the cell value before running your code. For example, to skip 'REMARKS' in column D, type: If Range("B" & i).Value <> "" And UCase(Trim(Range("D" & i).Value)) <> "REMARKS" Then

4
Nest your existing logic

Place your data modification, appending, or filling logic immediately after the IF statement, and close it with an 'End If'. This ensures the logic only runs for cells that do not contain the specified text.

Use an IF Condition with UCase and Trim to Skip Cells
Tip for reliable text matching: Using the UCase() function converts the cell text to uppercase before comparing, and Trim() removes leading or trailing spaces. This ensures 'Remarks ' or 'remarks' are properly ignored.
Advanced Macros in WPS Office

Easily Edit and Run VBA Macros in WPS Spreadsheet

WPS Spreadsheet provides robust support for Excel VBA macros. You can seamlessly run, edit, and troubleshoot your scripts to skip specific text cells directly within a familiar Developer interface.

  1. 1. Open your file in WPS Spreadsheet: Launch WPS Office and open your macro-enabled workbook (.xlsm).
  2. 2. Access the Developer Tab: Navigate to the 'Developer' tab on the top ribbon menu and click on 'VBA Editor' to view your code.
  3. 3. Edit and run your code: Update your script with the IF condition to skip specific text cells, then click the 'Run' button to process your data.
Highly compatible with Microsoft Excel .xlsm and VBA scriptsFamiliar Developer tab interface for writing and editing codeLightweight application ensuring fast macro executionFree and easy to download with cross-platform support
microsoft office alternative - wps office

Frequently Asked Questions

How do I ignore cells containing partial text in VBA?

To skip cells that contain a specific word anywhere in the text (rather than an exact match), use the InStr function in your condition. For example: If InStr(1, Range("D" & i).Value, "REMARKS", vbTextCompare) = 0 Then.

Why isn't my VBA code skipping the text properly?

This usually happens due to hidden leading or trailing spaces, or case sensitivity issues. Ensure you wrap your cell value reference with Trim() and UCase() to standardize the text before comparing it to your target string.

Can I skip multiple different words in the same column?

Yes, you can string together multiple conditions using the 'And' operator in your IF statement, or use a 'Select Case' block to easily evaluate and skip multiple different text values.

How can I skip completely empty cells in my VBA loop?

You can add a check for empty strings in your IF statement by adding: Range("D" & i).Value <> "" to ensure blank cells are also ignored during processing.