View Single Post
 
Old 10-10-2023, 11:34 PM
RobiNew RobiNew is offline Windows 10 Office 2016
Competent Performer
 
Join Date: Sep 2023
Posts: 208
RobiNew is on a distinguished road
Question

I have the following macro to find any character before minus. Is it possible to use the equivalent of '^?' instead of the long string in .Text? Can someone help? Thanks!



Code:
Sub CharPlusMinus()
'Find ANY character before -
Dim xRng As Range, iType As Integer
For iType = 1 To 2
Set xRng = ActiveDocument.StoryRanges(iType)
  With xRng.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchWildcards = False
'Find any character before -
        .Text = "[!ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÀÄÇÈÒÖÙÜßçàäèéìòóöùü0123456789]-[!ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÀÄÇÈÒÖÙÜßçàäèéìòóöùü0123456789]"
'    .Text = "^?-"
    .Execute
  End With
Next iType
End Sub
Reply With Quote