![]() |
#5
|
|||
|
|||
![]()
I understand - replace each variable twice.
This works for me: Sub Demo() 'replace each variable twice 'https://www.msofficeforums.com/word-vba/49582-vba-replace-repeated-single-variable-variable-list.html Application.ScreenUpdating = False Dim StrRep As String, i As Long, k As Long: k = 1 StrRep = "red|white|blue" '########## With ActiveDocument.Range.Find .ClearFormatting .Replacement.ClearFormatting .Forward = True '.Wrap = wdFindStop .Wrap = wdFindContinue .MatchWildcards = True .Text = "<VAR>" '############## .Execute For i = 0 To UBound(Split(StrRep, "|")) '0 .Replacement.Text = Split(StrRep, "|")(i) Do While .Found .Execute Replace:=wdReplaceOne, Forward:=True 'we need to replace 2 consecutive occurances! k = k + 1 If k > 2 Then 'only twice Exit Do End If Loop k = 1 Next End With |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
I want to create a bar chart of multiple variable. Then I need to draw trend lin of those variable | shimulsiddiquee | Excel | 1 | 05-16-2017 07:39 AM |
![]() |
tanzinim | Word VBA | 4 | 12-30-2015 01:40 PM |
Run Time Error '91': Object variable or With block variable not set using Catalogue Mailmerge | Berryblue | Mail Merge | 1 | 11-13-2014 05:36 PM |
![]() |
JUST ME | Word VBA | 4 | 03-25-2014 06:56 AM |
![]() |
tinfanide | Excel Programming | 2 | 06-10-2012 10:17 AM |