Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 09-02-2021, 05:39 PM
Guessed's Avatar
Guessed Guessed is offline Help with a script to find Duplicate data in the same row of a table or tables Windows 10 Help with a script to find Duplicate data in the same row of a table or tables Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
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

I'm going to assume that you have a regular table (no merged cells) and at least 2 columns and the code should be comparing the words in the first cell with all other cells on that row (like the original email). If these assumptions are correct then this modification to Paul's very elegant code should work.
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
  For Each Tbl In ActiveDocument.Tables
    With Tbl
      For i = 1 To .Rows.Count
        Set Rng = .Rows(i).Range
        Rng.Start = .Cell(i, 2).Range.Start
        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
  Application.ScreenUpdating = True
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
 

Tags
duplicate in tables, help please, highlight cells



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help to Script to align all the tables only as of a section to end of doc? Cendrinne Word VBA 4 04-05-2021 11:37 AM
Can Excel find Duplicate entries when only part of the cell's data is a duplicate of another cell? jsisley Excel 1 07-21-2017 09:20 AM
Help with a script to find Duplicate data in the same row of a table or tables VBA Table – Search All Tables - Find & Replace Text in Table Cell With Specific Background Color jc491 Word VBA 8 09-30-2015 06:10 AM
Script starts nesting tables without reason selman555 Word VBA 1 10-17-2014 01:01 AM
Pivot Table Duplicate Data cnw Excel 0 08-31-2012 08:24 AM

Other Forums: Access Forums

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