View Single Post
 
Old 01-04-2024, 08:22 AM
vivka vivka is offline Windows 7 64bit Office 2016
Expert
 
Join Date: Jul 2023
Posts: 293
vivka is on a distinguished road
Default

Hss001, try this one:
Code:
Sub Find_Wd_N_Select_Sent()
'In the selected range, find the inputboxed wd & select the 1st sentence it is in.

Dim oRng As range
Dim strWd As String
    
    Set oRng = selection.range
    strWd = InputBox("Enter the word to find", "FIND")
    With oRng.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .text = strWd
        .Replacement.text = ""
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchWildcards = False
        If .Execute Then
            oRng.Select
            selection.Extend: selection.Extend: selection.Extend
       End If
    End With
    Set oRng = Nothing
End Sub
Reply With Quote