How to Search Excel Data, Highlight Words, and Count Matches
Question details
The user wants to filter spreadsheet rows by a search term, count the total matches, and highlight the specific matched words within cells.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Searching and analyzing text data in spreadsheets to find occurrences of specific words and make them visually stand out for easier reading.
- Observed behavior
- Standard conditional formatting highlights the entire cell instead of just the matching text, requiring alternative methods like VBA and specific formulas to achieve the desired result.
Before using VBA macros to highlight text, ensure your spreadsheet is saved as a Macro-Enabled Workbook (.xlsm) and that macros are enabled in your security settings.
Use Formulas to Filter Data and Count Word Matches
Use wildcard formulas like COUNTIF or SUMPRODUCT to easily count occurrences of a specific word across your dataset, and apply AutoFilter to view the results.
Select a designated empty cell (for example, A1) to act as your dynamic search input box.
To count occurrences containing the searched word, enter the formula =COUNTIF(Range, "*"&A1&"*") where 'Range' is the group of cells you want to search.
Select your data headers, go to the 'Data' tab, and click 'Filter'. Click the dropdown arrow on your target column, select 'Text Filters', then 'Contains...', and enter your search term to hide non-matching rows.
Highlight Specific Words Within a Cell Using VBA
Since standard conditional formatting highlights the whole cell, use a VBA macro to format only the specific matching characters.
Easily Search, Filter, and Highlight Data in WPS Spreadsheet
WPS Spreadsheet offers powerful built-in tools for data filtering, conditional formatting, and formula calculations. It fully supports VBA macros, allowing you to run custom scripts to highlight specific words within cells just like you would in Microsoft Excel.
- 1. Open your data: Open your spreadsheet in WPS Office and select the data range you wish to search.
- 2. Apply filters: Go to the 'Data' tab and click 'AutoFilter' to easily filter rows by your specific search term.
- 3. Count or highlight: Use the =COUNTIF() function to count text matches, or access the 'Developer' tab to run your text-highlighting VBA script.

Frequently Asked Questions
Why does conditional formatting highlight the whole cell instead of just the word?
Standard conditional formatting evaluates the cell value as a whole. If the condition is met, the formatting rules are applied to the entire cell background or font. To format only a specific part of the text within a cell, you must use a VBA macro.
How do I count partial text matches in a range?
You can use the COUNTIF function combined with asterisks as wildcards. For example, =COUNTIF(A2:A100, "*apple*") will count any cell in the range that contains the word 'apple', regardless of what text comes before or after it.
Can I filter data based on a cell value dynamically?
Yes, you can use Excel's Advanced Filter feature or set up a VBA Worksheet_Change event to automatically hide rows that do not match the search term entered in your designated input cell.




