Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-14-2021, 02:55 PM
NoLockdownsLOL NoLockdownsLOL is offline replace specific text within brackets Windows 10 replace specific text within brackets Office 2019
Novice
replace specific text within brackets
 
Join Date: Jul 2021
Location: Brisbane, Australia
Posts: 4
NoLockdownsLOL is on a distinguished road
Default replace specific text within brackets

Hi



I have no idea where to start with this one (can clear all text within parenthesis no problem but i specifically need to delete as follows)

I am looking to delete all text with the following criteria when in parenthesis

some start with

(formerly )

and some are

(formerly John Wilson)

with John Wilson being totally random could be any combination up to 25 characters

End result - all deleted including parenthesis


Any help greatly appreciated

Thanks Steve


The following works for (formerly ) as above but needing to catch (formerly John Wilson) << John Wilson could be anything random

Sub replacetext()
Dim test
test = "(formerly )"

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = test
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Last edited by NoLockdownsLOL; 07-14-2021 at 05:04 PM.
Reply With Quote
  #2  
Old 07-14-2021, 05:33 PM
Guessed's Avatar
Guessed Guessed is offline replace specific text within brackets Windows 10 replace specific text within brackets Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 2,724
Guessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to behold
Default

Find and replace dialog
Find: \(formerly[a-zA-Z ]{1,25}\)
Replace with: leave it empty
Tick the Use wildcards checkbox
Replace All
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 07-14-2021, 06:16 PM
NoLockdownsLOL NoLockdownsLOL is offline replace specific text within brackets Windows 10 replace specific text within brackets Office 2019
Novice
replace specific text within brackets
 
Join Date: Jul 2021
Location: Brisbane, Australia
Posts: 4
NoLockdownsLOL is on a distinguished road
Default

Thanks Guessed

Works a treat , thanks a million fellow Aussie (i'm in Brisbane)

I just found one anomaly, names with an apostrophe for Example D'arcy or similar ?


P.S
Love the Avatar, Gary Larson The Far Side i was a huge fan back in the day (he retired in 1995!)
Reply With Quote
  #4  
Old 07-15-2021, 12:01 AM
Guessed's Avatar
Guessed Guessed is offline replace specific text within brackets Windows 10 replace specific text within brackets Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 2,724
Guessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to behold
Default

NoLockdownsLOL - at least it wasn't a dig at State of Origin last night.

You can try adding the apostrophe into the wildcard search box
Find: \(formerly[a-zA-Z' ]{1,25}\)
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #5  
Old 07-15-2021, 05:46 PM
NoLockdownsLOL NoLockdownsLOL is offline replace specific text within brackets Windows 10 replace specific text within brackets Office 2019
Novice
replace specific text within brackets
 
Join Date: Jul 2021
Location: Brisbane, Australia
Posts: 4
NoLockdownsLOL is on a distinguished road
Default

well SOO we still have our tails between our legs from the previous smashings lol

re the apostrophe - tried that unsuccessfully , tried some variants w/out luck also
Reply With Quote
  #6  
Old 07-15-2021, 07:23 PM
Guessed's Avatar
Guessed Guessed is offline replace specific text within brackets Windows 10 replace specific text within brackets Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 2,724
Guessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to behold
Default

Non-wildcard find and replaces don't care about the variants of apostrophes but Wildcard searches do. A dumb quote is only one of the apostrophe types - we also have an opening smart quote, closing smart quote and an official apostrophe. See Replacing Some Smart Quotes (Microsoft Word) for more detail.

You will need to find out what particular apostrophe variant is in play here and enter that by holding the Alt key down and typing 0145 or 0146 or 0147 or 0148. You could cover all the bases by adding all of them.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #7  
Old 07-15-2021, 07:34 PM
NoLockdownsLOL NoLockdownsLOL is offline replace specific text within brackets Windows 10 replace specific text within brackets Office 2019
Novice
replace specific text within brackets
 
Join Date: Jul 2021
Location: Brisbane, Australia
Posts: 4
NoLockdownsLOL is on a distinguished road
Default

Thanks Andrew, good call, will test all the variants .............


Cheers


EDIT

You could cover all the bases by adding all of them.


Did this and worked - boom

Legend, thanks for your help

Go the lions!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
replace specific text within brackets Enclose All Instances of a Specific Custom Style in Brackets Matt C Word VBA 7 05-30-2021 04:52 AM
replace specific text within brackets find/replace all text not a specific colour? LQuinn Word VBA 3 04-06-2021 04:51 PM
replace specific text within brackets find and delet all text within brackets and the brackets themselves wrdy Word 2 08-03-2017 06:55 PM
replace specific text within brackets Find and Replace - How to insert brackets around all numbers in a doc Natedogg Word 2 05-21-2015 07:16 AM
replace specific text within brackets Find/Replace Brackets Problem fatso Word 2 08-04-2011 11:34 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:11 AM.


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