Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-27-2024, 10:58 AM
vivka vivka is offline Searching for the lone string on a line that starts with a particular character Windows 7 64bit Searching for the lone string on a line that starts with a particular character Office 2016
Expert
 
Join Date: Jul 2023
Posts: 293
vivka is on a distinguished road
Default

Hi! It's not difficult:


Code:
Sub Test()
Dim oRng As range
    Set oRng = selection.range
    With oRng.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .text = "Y[! ]@" & Chr(13)
        .Format = False
        .Forward = True
        .MatchWildcards = True
        .Wrap = wdFindStop
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        If .Execute Then oRng.Select
    End With
 Set oRng = Nothing
End Sub
Modify the code to meet your needs.
Reply With Quote
  #2  
Old 03-27-2024, 11:55 AM
IndianaITGuy IndianaITGuy is offline Searching for the lone string on a line that starts with a particular character Windows 11 Searching for the lone string on a line that starts with a particular character Office 2019
Novice
Searching for the lone string on a line that starts with a particular character
 
Join Date: Mar 2024
Location: Martinsville, IN
Posts: 25
IndianaITGuy is on a distinguished road
Default

Quote:
Originally Posted by vivka View Post
Hi! It's not difficult:
Code:
Sub Test()
Dim oRng As range
    Set oRng = selection.range
    With oRng.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .text = "Y[! ]@" & Chr(13)
        .Format = False
        .Forward = True
        .MatchWildcards = True
        .Wrap = wdFindStop
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        If .Execute Then oRng.Select
    End With
 Set oRng = Nothing
End Sub
Modify the code to meet your needs.

You have me at a disadvantage with the value of .Text. I've looked but nothing good really jumped out at me with regard to special characters. Microsoft Help was not much. What is a good reference for all such special codes when searching for text? I've seen combinations of [], (), /, \, *, whatever. I just want to be able to recognize when there is one, specific word/string alone on a line that starts with a letter of my choosing. In my case it will be an X or Y. No whitespaces in this string.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Searching for the lone string on a line that starts with a particular character Word macro for deleting a line that starts with a specific character + deleting the line before eduardb Word 1 08-10-2022 03:17 AM
How to move a line to another line that starts with a chain selected in the 1st one? gloub Word VBA 24 03-19-2019 03:12 PM
Searching for string on a formula AMD2800 Excel 1 12-17-2014 10:41 AM
Searching for the lone string on a line that starts with a particular character Replace paragraph-marks (line-breaks) in tables with a character-string Aztec Word VBA 2 04-02-2013 10:52 PM
Searching for the lone string on a line that starts with a particular character Finding or searching ^ character in word document shahin3121 Word 2 03-05-2012 06:16 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:22 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft