Question : Remove duplicates in word 2003

Hi,

I have a word document..Please find the attachment to have a look at it...

In that i need to remove the duplicates...Any help...


Answer : Remove duplicates in word 2003

Ok - See attached file.

First, I did a search and replace replacing the comma with a paragraph marker and deleted the top four blank returns.
Secondly, I selected all and converted to table.
Thirdly, I ran a macro I found on the MVP site to delete duplicate rows (see attached code).
Lastly, I converted the table back to text, and did a search and replace for paragraph returns and replaced them with a comma.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
 Option Explicit
 
Public Sub DeleteDuplicateRows()
 
  ' Deletes Rows with duplicate text in first column.
  ' It will delete identical entries even if the case
  ' of the text is different.
 
  Dim oTable As Table
  Dim oRow As Range
  Dim oNextRow As Range
  Dim i As Long
  Dim txtCell As String
  Dim txtCellNext As String
 
  Set oTable = ActiveDocument.Tables(1)
  Set oRow = oTable.Rows(1).Range
 
  Application.ScreenUpdating = False
 
   For i = 1 To oTable.Rows.Count - 1
 
      Set oNextRow = oRow.Next(wdRow)
 
      txtCell = LCase(oRow.Cells(1).Range.Text)
      txtCellNext = LCase(oNextRow.Cells(1).Range.Text)
 
      If txtCell = txtCellNext Then
          oNextRow.Rows(1).Delete
      Else
          Set oRow = oNextRow
      End If
 
  Next i
 
  Application.ScreenUpdating = True
 
End Sub 
Open in New Window Select All
Random Solutions  
 
programming4us programming4us