![]() |
|
#1
|
|||
|
|||
![]()
Hello,
I'm looking for some assistance with a issue I'm having using VBA. I have a Table (2 Columns and hundreds of Rows) and I want to Compare the individual words in each Row (Column #1 of Row #1) against the individual words in (Column #2 of Row #1) and if there are "Duplicate Words in each Column (Capitalization does not matter) I want the words "Highlighted". Each successive Row will be compared against that Row's 2 Columns only. please see attachment sample table graphic. Any help would be greatly appreciated. Keith |
#2
|
||||
|
||||
![]()
Try:
Code:
Sub Demo() Application.ScreenUpdating = False Dim Tbl As Table, Rng As Range, strTxt As String, i As Long, j As Long Options.DefaultHighlightColorIndex = wdYellow With ActiveDocument For Each Tbl In .Tables With Tbl For i = 1 To .Rows.Count Set Rng = .Cell(i, 2).Range With .Cell(i, 1).Range For j = 1 To .Words.Count strTxt = Trim(.Words(j)) With Rng.Find .ClearFormatting .Text = strTxt With .Replacement .ClearFormatting .Highlight = True .Text = "^&" End With .Format = True .Forward = True .MatchCase = False .MatchWholeWord = True .MatchWildcards = False .Wrap = wdFindStop .Execute Replace:=wdReplaceAll End With Next End With Next End With Next End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
Thank You Very Much...
|
![]() |
Tags |
compare, duplicates, vba |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
AtaLoss | Word VBA | 37 | 09-22-2021 12:04 PM |
Word tables: prevent word from highlighting whole cell when I highlight text | skylark53 | Word | 2 | 08-04-2015 08:12 AM |
![]() |
JSC6 | Word VBA | 1 | 09-30-2014 08:22 PM |
Adapt a script used in Word to highlight words, to work in Outlook? | flatop | Outlook | 5 | 07-15-2014 01:07 PM |
permanently highlight searched words in word 2013 | arjay | Word | 4 | 08-16-2013 09:29 AM |