Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-02-2020, 06:36 AM
pjs15 pjs15 is offline Macro to delete all words with hyphens? Windows 10 Macro to delete all words with hyphens? Office 2019
Novice
Macro to delete all words with hyphens?
 
Join Date: Feb 2020
Posts: 7
pjs15 is on a distinguished road
Default Macro to delete all words with hyphens?

To create a custom dictionary of medical terms, I would like to remove all hyphenated words from a list of about 12,000 terms. I'm new to Word VBA and macros. Would this be possible to do?

If anyone has a macro like this, or could suggest an approach I could learn from, I would appreciate it.

pjs
Reply With Quote
  #2  
Old 02-02-2020, 01:46 PM
Guessed's Avatar
Guessed Guessed is offline Macro to delete all words with hyphens? Windows 10 Macro to delete all words with hyphens? Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Is each word in its own paragraph or is there spaces between words? Assuming they are paragraphs, a search and replace would do it. You can record this as a macro if you wanted to.

Find: [a-zA-Z]{1,}-[a-zA-Z]{1,}^13
Replace: Nothing <- don't put anything in the replace box
Wildcards turned on
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 02-04-2020, 10:45 PM
macropod's Avatar
macropod macropod is online now Macro to delete all words with hyphens? Windows 7 64bit Macro to delete all words with hyphens? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

A morecomprehensive wildcard Find/Replace that accommodates non-breaking hyphens, em-dashes and en-dashes:
Find = <[! ]@[^~^+^=\-]*>
Replace = nothing

If the words are whole paragraphs, use:
Find = ^13[!^13]@[^~^+^=\-]*^13
Replace = ^p
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to delete all words with hyphens? How to delete all but specific words in Microsoft Word document Landhaus416 Word 3 09-19-2018 03:00 PM
Macro to delete all words with hyphens? Using VBA to delete text between two words warddegeest Word VBA 1 01-12-2018 04:24 AM
Macro to delete all words with hyphens? Is there a possibility to remove all the hyphens inside words...? dabbler Word 1 01-17-2015 04:37 AM
Macro to delete all words with hyphens? How to find and delete duplicate words in doc cinvest Word 1 09-29-2014 08:34 PM
Macro to delete all words with hyphens? Mask mode and hyphens cyndor Word 6 07-25-2012 06:40 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:57 AM.


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