VBA & Macro Problems

How to Search an Entire Excel Workbook for Multiple Terms and Cell Locations

Emma BrownEmma Brown Nov 10, 2026 869 views

Question details

The user needs a method to search for a list of specific names or phrases across every worksheet in a workbook and return the sheet names and exact cell addresses where the terms are found.

How to Search an Entire Excel Workbook for Multiple Terms and Cell Locations
Product
Microsoft Excel
Device & OS
not provided
Scenario
Searching for multiple text strings, including partial matches embedded within paragraphs, across all sheets in a large workbook to generate a comprehensive location list.
Observed behavior
Standard formulas are inefficient for scanning every cell across multiple worksheets and can cause Excel to freeze or crash if the search range is not restricted to the used data area.
Before you start

Before running any workbook-wide search macros, save a backup of your file and identify the specific cell ranges (like A1:BA1000) that contain data to prevent your spreadsheet application from freezing.

Solution 1Recommended

Use a VBA Macro for Workbook-Wide Search

A VBA macro is the most efficient way to loop through a list of search terms and find partial or exact matches across all worksheets without freezing the application.

Formulas cannot efficiently scan every cell in every worksheet without causing massive performance drops. By using VBA, you can loop through the search terms and programmatically test each cell in the UsedRange of every worksheet.

The macro utilizes the InStr function to identify text embedded within longer paragraphs and outputs the matched results (Search Term, Sheet Name, Cell Address) directly into a dedicated results table.

1
Open the VBA Editor

Press Alt + F11 to open the Visual Basic for Applications Editor, then navigate to Insert > Module to create a new blank script.

2
Define the search loop

Write a script that declares an array of your search terms and uses a 'For Each ws In ActiveWorkbook.Worksheets' loop to iterate through all tabs.

3
Restrict the search range

Inside the sheet loop, restrict your cell scanning to 'ws.UsedRange' to ensure the macro only processes cells containing data, skipping millions of blank cells.

4
Check for matches using InStr

Use the 'InStr(1, cell.Value, searchTerm, vbTextCompare)' function to check if the cell's content contains the search term, including partial matches in paragraphs.

5
Record the results

If a match is greater than 0, append the search term, ws.Name, and cell.Address to a newly created summary worksheet.

Use a VBA Macro for Workbook-Wide Search
Performance Tip: Using the UsedRange property is crucial because searching an entire worksheet (which contains over 17 billion cells) will almost certainly cause Excel to become unresponsive.
Efficient Spreadsheet Management

Easily Search and Manage Large Datasets with WPS Office

WPS Spreadsheet offers powerful data processing capabilities, full VBA support in its advanced versions, and an intuitive 'Find All' feature to help you locate specific terms across entire workbooks effortlessly.

  1. 1. Open your file: Launch WPS Spreadsheet and open your multi-sheet workbook.
  2. 2. Access the Find tool: Press Ctrl + F to bring up the Find and Replace dialog.
  3. 3. Configure workbook search: Click the 'Options' button, change the 'Within' setting to 'Workbook', and type your target keyword.
  4. 4. View all locations: Click 'Find All' to instantly generate a comprehensive list of all matching cell locations across your document.
Fully compatible with Microsoft Excel formats (.xlsx, .xls, .xlsm)Advanced VBA macro support for automating complex multi-term searchesLightweight application that handles large datasets without freezingIntuitive interface with powerful built-in Find and Replace tools
microsoft office alternative - wps office

Frequently Asked Questions

Why does my spreadsheet crash when searching the whole workbook using formulas?

Spreadsheets crash because an entire modern worksheet contains over 17 billion cells. Applying array or complex search formulas across multiple sheets forces the application to calculate massive ranges, quickly exhausting your computer's memory. Always restrict formula searches to the used range.

Can Power Query search a workbook for multiple terms?

Yes, Power Query can be used to append all your worksheets into a single master table. You can then apply a conditional column or merge it with a separate table containing your list of search terms. This is a robust, code-free alternative to VBA for extracting matching records.

How do I find a partial text match inside a long paragraph in a cell?

In VBA, you can use the InStr function to check if a specific substring exists within the cell's text. In standard formulas, you can use the SEARCH or FIND functions combined with wildcards (like *term*) to locate partial matches embedded in paragraphs.

Can I export the 'Find All' results to a new sheet?

The built-in 'Find All' dialog does not have a native export button. To get a list of results in a new sheet, you will need to use a VBA macro that loops through the matches and writes the sheet names and cell addresses to a designated summary worksheet.