Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-18-2014, 07:51 AM
paulkaye paulkaye is offline Find-replace using part of what was found in the replacement text Windows 7 64bit Find-replace using part of what was found in the replacement text Office 2007
Advanced Beginner
Find-replace using part of what was found in the replacement text
 
Join Date: Nov 2011
Posts: 84
paulkaye is on a distinguished road
Default Find-replace using part of what was found in the replacement text

Hi,
I've tried to figure this out using various guides, but can't get it right, even though I know it should be simple! I want to run a find-replace that finds:

Quote:
any one of products X-Y
and replaces it with:



Quote:
product X
Where X and Y are variable numbers, and the X in the replacement text is the same as the X in the found text.

Also, would it be straightforward to have a macro do this? I perform this find-replace quite frequently.

Many thanks in advance,
Paul
Reply With Quote
  #2  
Old 12-18-2014, 03:15 PM
macropod's Avatar
macropod macropod is offline Find-replace using part of what was found in the replacement text Windows 7 64bit Find-replace using part of what was found in the replacement text Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,343
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You can do that with a wildcard Find/Replace, where:
Find = any one of products ([0-9]@)-[0-9]@>
Replace = product \1

You can use the macro recorder to record the above as a macro - in this case the result is about as efficient as a hand-written macro.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 12-22-2014, 12:39 AM
paulkaye paulkaye is offline Find-replace using part of what was found in the replacement text Windows 7 64bit Find-replace using part of what was found in the replacement text Office 2007
Advanced Beginner
Find-replace using part of what was found in the replacement text
 
Join Date: Nov 2011
Posts: 84
paulkaye is on a distinguished road
Default

Thank you - that works well. However, it didn't work the first time I ran it - which I discovered was because I had track changes on. The replaced text said "Xproduct ," (instead of "product X, "). Also note the space before the comma, instead of after the comma. If I display insertions and deletions, it looks like this: "any onXe of claims X-Yclaim ," (where strikethrough marks deletions, and underline marks insertions).

It works fine with track changes off, but I would ideally want to run this find-replace with track changes on. Is there any way to remedy this problem?

Paul
Reply With Quote
  #4  
Old 12-22-2014, 02:52 AM
macropod's Avatar
macropod macropod is offline Find-replace using part of what was found in the replacement text Windows 7 64bit Find-replace using part of what was found in the replacement text Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,343
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Unfortunately, that just how things are with Track Changes. Anything more sophisticated would require a macro.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find-replace using part of what was found in the replacement text Find text, format part of text in italic d4okeefe Word VBA 18 06-30-2022 11:35 PM
Macro to find coloured text and replace with form-field/formtext containing that text tarktran Word VBA 1 11-26-2014 08:12 AM
Find-replace using part of what was found in the replacement text Created VBA to Find and Replace in Body, Header and Footer with Highlighting the replacement text QA_Compliance_Advisor Word VBA 11 09-23-2014 04:40 AM
Find-replace using part of what was found in the replacement text Replace text with Quick Part using VBA dmarie123 Word VBA 10 09-18-2014 01:03 AM
Find-replace using part of what was found in the replacement text Bad view when using Find and Find & Replace - Word places found string on top line paulkaye Word 4 12-06-2011 11:05 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:27 PM.


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