How to Automatically Number Bible Verses Using a Word VBA Macro
Question details
The user needs to find Bible verse references (e.g., 'Gen 1:1') in a document and replace them with sequential superscript numbers using a VBA macro, ensuring the numbering restarts for each new chapter.

- Product
- Word
- Device & OS
- not provided
- Scenario
- Formatting a text-heavy document containing multiple Bible verse references that need standardized numbering.
- Observed behavior
- Requires a macro that scans paragraphs, detects book/chapter/verse patterns, resets the counter when the chapter changes, replaces text with sequential numbers, and applies superscript.
Before running any VBA macro, ensure you save a backup copy of your document, as macro actions typically cannot be reversed using the standard Undo function.
Use a VBA Macro to Scan and Replace Verse References
Implement a custom VBA macro in the Developer environment to automatically detect book/chapter/verse patterns, apply superscript formatting, and manage chapter-based numbering counters.
By utilizing Visual Basic for Applications (VBA), you can write a script that loops through the paragraphs in your document, identifies specific text patterns using regular expressions (Regex) or Word's built-in Find function, and replaces them accordingly.
The logic must involve variables to track the current chapter number so that the verse counter can be reset to 1 whenever a new chapter is encountered.
Press Alt + F11 on your keyboard while in Word to open the Microsoft Visual Basic for Applications window.
In the top menu, click 'Insert', and then select 'Module' to create a blank script window for your new macro.
Paste your custom VBA code designed to search for Bible references (like 'Gen 1:1'). Ensure the code includes a loop for paragraph scanning, a variable for the chapter counter, and a Font.Superscript = True command for the replacement text.
Press F5 or click the green 'Run' triangle button in the toolbar. The macro will scan the active document and process the text replacements.

Run Custom VBA Macros Seamlessly in WPS Writer
WPS Office supports VBA, allowing you to run custom macros to automate repetitive tasks like numbering Bible verses, formatting text, and organizing large documents efficiently.
- 1. Download WPS Office: Install WPS Office from the official website and launch WPS Writer.
- 2. Access the Developer Tools: Navigate to the 'Tools' tab on the ribbon and click on 'Developer' to access advanced options.
- 3. Open the VBA Editor: Click 'VBA Editor' to open the scripting environment.
- 4. Run Your Macro: Insert a new module, paste your Bible verse numbering code, and execute it to format your document automatically.

Frequently Asked Questions
Why is my VBA macro skipping some Bible verses?
This usually occurs if the text pattern in your document doesn't strictly match the search criteria in your macro code. Ensure there are no unexpected spaces, typos, or different punctuation marks (like a period instead of a colon) in the unrecognized verses.
How do I make the Developer tab visible in Word?
Go to File > Options > Customize Ribbon. In the right-hand list of main tabs, check the box next to 'Developer', then click OK to display it on your ribbon.
Can I undo a macro after it replaces my text?
Standard VBA macro executions clear the Undo history. You generally cannot use Ctrl+Z to revert the changes, which is why testing on a backup copy is highly recommended.
How do I format the replacement numbers as superscript in the code?
When assigning the replacement text object in VBA, you can format it using the command 'Replacement.Font.Superscript = True' within your Find and Replace block.




