Share via

Word find 12 Font only it is also finding Font 10.5

SteveD 430 Reputation points
2026-04-27T21:22:15.1833333+00:00

Ho from Steve

Can the below script please find 12 Font.

Not Font 10.5

Sub Horse_Above_10()

With Selection.Find

    .ClearFormatting

    .Font.Size = 12

    .Text = "\) [0-9]{2,} [A-Z]"

    .Replacement.Text = ""

    .Forward = True

    .Wrap = wdFindStop   'Stop at end; do not continue from top

    .Format = False

    .MatchCase = False

    .MatchWholeWord = False

    .MatchAllWordForms = False

    .MatchSoundsLike = False

    .MatchWildcards = True

End With

'Find next occurrence from current cursor position

If Selection.Find.Execute Then

    'Now Selection is on the found text

    Selection.MoveLeft Unit:=wdCharacter, Count:=1

    Selection.Delete Unit:=wdCharacter, Count:=1

    Selection.MoveDown Unit:=wdLine, Count:=1

End If
```End Sub

Developer technologies | Visual Basic for Applications

Answer accepted by question author

  1. Surya Amrutha Vaishnavi Lanka (INFOSYS LIMITED) 2,195 Reputation points Microsoft External Staff
    2026-05-05T06:00:55.2333333+00:00

    Thank you for reaching out.

    Please let us know whether the issue has been resolved or is still occurring. If the issue is resolved, we will proceed with closing this thread. If you face any further issues, please let us know and we’ll be happy to assist you.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Q&A Assist
    2026-04-27T21:22:25.61+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    Set the find to search by formatting and not treat the font size as part of the wildcard text pattern.

    In the current code, .Format = False tells Word to ignore the .Font.Size = 12 condition, so the wildcard text pattern is applied regardless of font size, which is why text in 10.5 pt is also found.

    Adjust the macro as follows:

    Sub Horse_Above_10()
    
        With Selection.Find
            .ClearFormatting
            .Text = "\) [0-9]{2,} [A-Z]"   ' wildcard pattern
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindStop
            .Format = True                 ' <‑‑ enable formatting filter
            .Font.Size = 12                ' <‑‑ restrict to 12 pt only
            .MatchCase = False
            .MatchWholeWord = False
            .MatchAllWordForms = False
            .MatchSoundsLike = False
            .MatchWildcards = True
        End With
    
        If Selection.Find.Execute Then
            Selection.MoveLeft Unit:=wdCharacter, Count:=1
            Selection.Delete Unit:=wdCharacter, Count:=1
            Selection.MoveDown Unit:=wdLine, Count:=1
        End If
    
    End Sub
    

    Key change: .Format = True ensures the .Font.Size = 12 criterion is applied, so only text that matches the wildcard pattern and is in 12‑point font is found, not 10.5.


    References:

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.