Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
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,185
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
  #2  
Old 09-02-2021, 05:42 PM
Cendrinne's Avatar
Cendrinne Cendrinne 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 2019
Competent Performer
Help with a script to find Duplicate data in the same row of a table or tables
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 200
Cendrinne is on a distinguished road
Default OK Andrew, I'll test it right now and let you know :)

I hope one day, I'll get it, understand better. Well been better since day 1 in Word, 5 years ago. OK let me test it
Reply With Quote
  #3  
Old 09-02-2021, 06:28 PM
Cendrinne's Avatar
Cendrinne Cendrinne 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 2019
Competent Performer
Help with a script to find Duplicate data in the same row of a table or tables
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 200
Cendrinne is on a distinguished road
Red face Andrew, I'm so sorry, it did work!!!!!

I'm so sorry, I forgotten that I had removed the option of showing highlights. Because others in the same document, uses a software where there's different colors of highlighted stuff. I get too confused, so I had removed it. I totally forgotten.

So you are right, it works.

I truly am sorry. You did an amazing job. I'll try to analyze it when I'll have more time.

again, humble appologies
Reply With Quote
Reply

Tags
duplicate in tables, help please, highlight cells

Thread Tools
Display Modes


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 02:52 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