Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-02-2021, 12:59 AM
Shelley Lou Shelley Lou is offline VBA to only remove word at beginning and not additional instances within the same paragraph Windows 10 VBA to only remove word at beginning and not additional instances within the same paragraph Office 2016
Expert
VBA to only remove word at beginning and not additional instances within the same paragraph
 
Join Date: Dec 2020
Posts: 259
Shelley Lou is on a distinguished road
Default VBA to only remove word at beginning and not additional instances within the same paragraph

I have the following code that removes instances of the word 'means' that follow after the bold definition text. However, the macro also removes any additional word 'means' that may be within the same paragraph as normal text. What can I add to the code that would stop this from happening. Thanks

Remove the word means TEST DOC June 2021.docx

Code:
Sub DefMeans()
Dim aRng As Range, aPara As Paragraph
  Set aRng = ActiveDocument.Range
  For Each aPara In aRng.Paragraphs
  Next aPara
  With aRng.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "[:;, ^t]{1,5}means[:;, ]{1,5}"
    .Replacement.Text = "^t"
    .MatchWildcards = True
    .Execute Replace:=wdReplaceAll
End With
End Sub

Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA to only remove word at beginning and not additional instances within the same paragraph Replace a character only if it is at the beginning of the paragraph. donpopo Word 2 11-11-2018 11:32 PM
VBA to only remove word at beginning and not additional instances within the same paragraph Word macro to insert text at the beginning of paragraph but skip tables ashalles135 Word VBA 5 09-26-2018 09:49 AM
VBA to only remove word at beginning and not additional instances within the same paragraph Space tab at the beginning of each paragraph in a chapter village Word 3 07-20-2018 01:48 AM
VBA to only remove word at beginning and not additional instances within the same paragraph word macro To insert text at the beginning and at end of paragraph ArieH Word VBA 20 09-10-2017 04:23 PM
VBA to only remove word at beginning and not additional instances within the same paragraph remove row from dataset for additional calculations canajun Excel 1 01-06-2015 06:38 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:40 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