Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-16-2018, 06:08 PM
schausberger2019 schausberger2019 is offline VBA Different replacement for each word in the string Windows 7 64bit VBA Different replacement for each word in the string Office 2010
Novice
VBA Different replacement for each word in the string
 
Join Date: Nov 2018
Posts: 3
schausberger2019 is on a distinguished road
Default VBA Different replacement for each word in the string

Hello Everybody.
I have a code able to highlight all the words in the string keywords = "if,then,from,to,all,first,between,first,last, of); and start a new line for each one.
My request here is:


first, my list is really long -SO- how can I break it or separated in different lines.
Second: how to replace each word in the list for different replacement for each one.
This is the code I have:
Code:
Sub HiLightList()
Application.ScreenUpdating = False
Dim keywords As String, Rng As Range, i As Long
keywords = "if,then,from,to,all,first,between,first,last,of,and,or,print,find,swap,check,print,count,when,require,do not,with,but, rather than,where,is not,as,in,an,is,by,are,on,for,because,some,before,after,also,under,inside,around,into,next to,often,let,delete,copy,find,calculate,check,print,until,was,were,behind,had been"

For i = 0 To UBound(Split(keywords, ","))
  Set Rng = ActiveDocument.Range
  With Rng.Find
    .ClearFormatting
    .Text = Split(keywords, ",")(i)
    .Replacement.ClearFormatting
    .Replacement.Highlight = True
    .Replacement.Text = "^l^&"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
   .MatchCase = False
    .MatchWholeWord = True
  
    .MatchWholeWord = True
    .Execute Replace:=wdReplaceAll
  End With
Next
Set Rng = Nothing
Application.ScreenUpdating = True
End Sub
Thank you for reading this post.
Reply With Quote
 

Tags
vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Different replacement for each word in the string Wildcard replace any string in context with a specified string wardw Word 7 05-07-2018 09:13 AM
VBA Different replacement for each word in the string How can I compare a string in a cell to another string? Amitti Word VBA 2 04-10-2017 07:35 PM
How to find all string within string. PRA007 Word VBA 18 02-12-2016 08:11 PM
VBA Different replacement for each word in the string Word Replacement Option mattyra Word 7 02-11-2015 11:13 PM
VBA Different replacement for each word in the string Way to search for a string in text file, pull out everything until another string? omahadivision Excel Programming 12 11-23-2013 12:10 PM

Other Forums: Access Forums

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