View Single Post
 
Old 02-10-2022, 12:39 AM
Guessed's Avatar
Guessed Guessed is offline Windows 10 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

Try this version for the duplicate row deletion
Code:
Public Sub DeleteDuplicateRows2()
  Dim xTable As Table, xRow As Range, xStr As String, xDic As Object
  Dim I As Long, J As Long, KK As Long, xNum As Long, iRow As Long, iRows As Long
  Dim aRng As Range, cRng As Range

  'Application.ScreenUpdating = False
  Set xDic = CreateObject("Scripting.Dictionary")
  If Selection.Tables.Count = 0 Then
    MsgBox "Macro must be run when a table is selected"
    Exit Sub
  Else
    Set xTable = Selection.Tables(1)
    iRows = xTable.Rows.Count
    For I = iRows To 3 Step -1
      Set aRng = xTable.Rows(I).Range
      aRng.Start = aRng.Cells(2).Range.Start
      For iRow = 3 To I - 1
        Set cRng = xTable.Rows(iRow).Range
        cRng.Start = cRng.Cells(2).Range.Start
        If aRng.Text = cRng.Text Then
          xTable.Rows(I).Delete
          Exit For
        End If
      Next iRow
    Next I
  End If
  Application.ScreenUpdating = True
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote