(Solved) – Non breaking space between date elements word vba


I’m trying to make sure the dates stay together and not break across lines.

The replacement text should have two non breaking spaces, one between 1 April, and one between April 2.

Sub SarahDates()
‘ Supposed to put a non breaking space between day, month and year.
    With Selection.Find
        .Text = “([0-9]) April ([0-9])”
        .Replacement.Text = “1 April 2”
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *