logo
search
Document Editing Problems

How to Find Whole Numbers Within a Range in Microsoft Word

Partner EditorPartner Editor Oct 1, 2026 868 views

Question details

The user needs to locate specific plain text whole numbers that fall within a defined mathematical range (e.g., 250–262) in a Microsoft Word document filled with thousands of numbers.

How to Find Whole Numbers Within a Specific Range in Microsoft Word
Product
Microsoft Word
Device & OS
not provided
Scenario
Searching through pasted index text for a specific range of plain text numbers, checking one range at a time.
Observed behavior
Word's default Find tool searches for text characters rather than numerical values, making it impossible to search for mathematical ranges natively without a custom script.
Before you start

Ensure your document is saved as a Macro-Enabled Document (.docm) and that you have enabled the Developer tab in your Word ribbon to access the Visual Basic editor.

Solution 1Recommended

Use a VBA Macro to Locate Numbers Within a Specified Range

Creating a custom VBA macro is the most effective way to evaluate plain text numbers mathematically and stop at values within your desired range.

Because Word's Find function searches for text characters rather than numerical values, it cannot natively search for mathematical ranges like '250 to 262'. A VBA macro can scan each word, check if it is a numeric value using word-boundary checks to avoid partial matches, and compare it against your defined minimum and maximum limits.

1
Enable Developer Tab

Go to File > Options > Customize Ribbon, and check the 'Developer' box in the right pane to reveal the Developer tab on your main menu.

2
Open the VBA Editor

Click the 'Developer' tab and select 'Visual Basic', or press Alt + F11 on your keyboard to launch the Microsoft Visual Basic for Applications window.

3
Insert a New Module

In the Visual Basic editor, click Insert > Module from the top menu to create a blank script window for your custom macro.

4
Paste Macro Code

Write or paste a VBA script that utilizes the Selection.Find object with wildcards ([0-9]{1,}) to find numeric strings. Have the script use CInt() or CLng() to check if the found number is greater than or equal to your minimum value and less than or equal to your maximum value.

5
Run the Macro

Close the VBA editor, place your cursor at the beginning of your Word document, navigate back to the Developer tab, click 'Macros', select your new macro, and click 'Run'.

Use a VBA Macro to Locate Numbers Within a Specified Range
Wildcard Search Limitations: While Word's Advanced Find with wildcards can find specific digit lengths or basic patterns, it cannot evaluate greater-than or less-than mathematical logic without VBA.
Free Microsoft Office alternative

Use WPS Office for Advanced Document Editing

If you are looking for a highly efficient and lightweight word processor, WPS Office offers a free and robust alternative to Microsoft Word. It provides advanced text processing capabilities and excellent compatibility with standard document formats.

  1. 1. Download WPS Office: Visit the official WPS website and download the free WPS Office suite for your operating system.
  2. 2. Open Your Document: Launch WPS Writer and easily open your existing Microsoft Word documents without losing formatting.
  3. 3. Utilize Editing Tools: Navigate to the Home tab to access familiar Find and Replace tools, streamlining your document editing process.
Completely free and lightweight office suiteFully compatible with Microsoft Word formats like .docx and .docFamiliar ribbon interface requires no learning curveBuilt-in advanced search features for complex text editing scenarios
microsoft office alternative - wps office

Frequently Asked Questions

Can I use regular expressions in Word to find a number range?

Word uses its own wildcard system rather than standard Regex. While you can search for a range of single digits (like [1-5]), you cannot search for mathematical values (like 250-262) using wildcards alone.

Why doesn't Word's built-in Find highlight numbers between 50 and 100?

Word's Find tool searches for text strings, not numerical values. It interprets '50' as the character '5' followed by '0', rather than a mathematical integer, making VBA necessary for value-based range searches.

Does this macro work for numbers inside field codes or page numbers?

No, this specific macro approach is designed for plain text numbers. If your numbers are generated by PAGE fields or automated indexes, the macro must be adjusted to read field code results rather than standard text strings.