• Delete Double Cells (Excel 97)

    Author
    Topic
    #366714

    Hello,

    I hope someone can help me with this. Can I write a macro so that I can delete all the rows that have the same data in a specific column?

    Viewing 0 reply threads
    Author
    Replies
    • #569734

      This code will delete all of the rows in that have duplicates in column A.

      Public Sub DelDups()
      Dim I As Long, J As Long, lMax As Long
          lMax = Worksheets("Sheet1").Range("A1").Offset(Worksheets("Sheet1").UsedRange.Rows.Count, 0).End(xlUp).Row - 1
          For I = lMax To 1 Step -1
              For J = I - 1 To 0 Step -1
                  If Worksheets("Sheet1").Range("A1").Offset(I, 0).Value = Worksheets("Sheet1").Range("A1").Offset(J, 0).Value Then
                      Worksheets("Sheet1").Range("A1").Offset(J, 0).EntireRow.Delete
                  End If
              Next J
          Next I
      End Sub
      
    Viewing 0 reply threads
    Reply To: Delete Double Cells (Excel 97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: