logo
search
list

Table of Content

Understanding the VBA Requirement for Specific word Font Input Sizes
Step-by-Step VBA Solution to Target Specific word Font Input
Advanced Find Alternative for word Font Input & UI Verification
How to Verify the Word Result
WPS Office: A Free Microsoft Office Alternative for Format Specific Text Based on Font Size in Word Using
Word FAQs About Format Specific Text Based on Font Size in Word Using VBA

How to Format Specific Text Based on Font Size in Word Using VBA

Posted by Steve K

calendar

2026-09-18

views

870

likes

4

When dealing with complex documents, running a standard find-and-replace macro can overwrite formatting you wanted to keep. The core requirement here is to ensure that a macro only alters text if the current word Font Input matches a highly specific size—in this case, 14.5. Standard wildcard searches cannot easily parse fractional font sizes across an array of 30+ different text strings, making a customized VBA loop utilizing

Understanding the VBA Requirement for Specific word Font Input Sizes

When dealing with complex documents, running a standard find-and-replace macro can overwrite formatting you wanted to keep. The core requirement here is to ensure that a macro only alters text if the current word Font Input matches a highly specific size—in this case, 14.5. Standard wildcard searches cannot easily parse fractional font sizes across an array of 30+ different text strings, making a customized VBA loop utilizing the rng.Font.Size property the only viable solution

The first practical checkpoint is not a generic restart; it is this exact action: Open your target document in Microsoft Word

Step-by-Step VBA Solution to Target Specific word Font Input

Follow these Word actions for Format Specific Text Based on Font Size in Word Using VBA in order. The key interface checkpoint is Top Navigation Menu.

UI-style illustration of Top Navigation Menu in Microsoft Word (VBA Editor), highlighting Module to create a blank script window
Click Insert > Module to paste the conditional font macro in a UI-style illustration based on the primary workflow.
  1. Open your target document in Microsoft Word
  2. Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor entry point
  3. In the top menu path, click Insert > Module to create a blank script window
  4. Paste the following exact VBA code into the module. This code adds the crucial If rng.Font.Size = 14.5 Then condition to check the font before applying changes
  5. Press F5 or click the green Run button in the toolbar
  6. Expected result: The script will iterate through the array. Only the words currently set to font size 14.5 will turn red, bold, and receive turquoise highlighting
  7. Verification: Check a target word in the document that was size 10.5; it should remain completely unformatted
Sub Track_Names2()



       Dim rng As Range



       Dim i As Long



       Dim TargetList As Variant



       TargetList = Array("AWAPUNI SYNTHETIC", "HAWERA", "ASCOT PARK", "HASTINGS", "PUKEKOHE", _



                         "NEW PLYMOUTH", "RICCARTON", "PHAR LAP", "WAVERLEY", "ROTORUA", _



                         "TAURANGA", "TRENTHAM", "WHANGANUI", "RICCARTON SYNTHETIC", "TE RAPA", _



                         "OAMARU", "TAUPO", "WOODVILLE", "RIVERTON", "WINGATUI", "MATAMATA", _



                         "ASHBURTON", "CROMWELL", "OTAKI-MAORI", "TE AROHA", "WINGATUI", _



                         "CAMBRIDGE SYNTHETIC", "ELLERSLIE", "WHANGANUI", "REEFTON", "KUMARA", _



                         "RUAKAKA", "TAUHERENIKAU", "GREYMOUTH")



       For i = 0 To UBound(TargetList)



           Set rng = ActiveDocument.Range



           With rng.Find



               .Text = TargetList(i)



               .Format = True



               .MatchCase = True



              .MatchWholeWord = False



              .MatchWildcards = False



              .MatchSoundsLike = False



              .MatchAllWordForms = False



               Do While .Execute(Forward:=True) = True



                   If rng.Font.Size = 14.5 Then



                      rng.Font.Bold = True



                      rng.Font.Color = wdColorRed



                       rng.HighlightColorIndex = wdTurquoise



                   End If



               Loop



           End With



       Next i



    End Sub

Advanced Find Alternative for word Font Input & UI Verification

  • Application: Microsoft Word (VBA Editor)
  • Menu/Pane: Top Navigation Menu
  • Selected Control: The "Insert" dropdown menu expanding to highlight "Module"
  • Callout Label: "Click Insert > Module to paste the conditional font macro"

How to Verify the Word Result

Use this outcome as the acceptance test: Verification: Check a target word in the document that was size 10.5; it should remain completely unformatted Keep the original state unchanged if the result cannot be confirmed.

WPS Office: A Free Microsoft Office Alternative for Format Specific Text Based on Font Size in Word Using

WPS Writer logo
WPS Presentation logo
WPS Spreadsheets logo
WPS PDF logo
Use Word, Excel, and PPT for FREE

For local work related to Format Specific Text Based on Font Size in Word Using VBA, WPS Office is a free Microsoft Office-compatible alternative. It does not reproduce every proprietary Word service or administrator control, so use the Microsoft steps above when the task depends on that specific platform.

If you need to keep working with local files related to “Format Specific Text Based on Font Size in Word Using VBA,” WPS Writer supports DOCX and RTF files, styles, comments, track changes, and PDF export, and WPS AI can draft, rewrite, summarize, or translate document text. Its free tier and familiar ribbon-style controls make it practical for opening, editing, and saving common Office-format files while the original Microsoft task is handled separately.

WPS Office alternative for local files related to Format Specific Text Based on Font Size in Word Using VBA
Continue compatible local document work in WPS Office while the Microsoft-side issue is resolved.
100% secure

Word FAQs About Format Specific Text Based on Font Size in Word Using VBA

How do I enable the Developer tab to access VBA?

Go to File > Options > Customize Ribbon. In the right-hand column under "Main Tabs," check the box next to "Developer" and click OK. You can now access the Visual Basic editor directly from the ribbon.

Can I change the VBA script to target a different font size?

Yes. In the provided script, locate the line If rng.Font.Size = 14.5 Then. Change 14.5 to your desired size, such as 10.5 or 12, before running the macro.

Will this macro work on Microsoft 365 and Office | Word | For home | Windows?

Yes, the VBA editor and the Font.Size property are fully supported in desktop versions of Microsoft 365 Word for Windows. Note that macros do not run in the web-browser version of Word.

How do I undo the formatting if the macro highlights the wrong words?

Unfortunately, VBA macro actions often clear the standard Undo (Ctrl+Z) history. Always save a backup copy of your document immediately before running a new macro. If a mistake occurs, close the document without saving and reopen the backup.

Steve K

Steve K. is a content writer who has vast experience in writing PDF formatting and conversions too. He has been using PDF tools for a very long time. During his free time, Steve K. also does art drawing which is one of his hobbies.