How to look for repeated rows and then delete one of them? requires VBA

前端 未结 5 2080
日久生厌
日久生厌 2020-12-12 00:05

I was wondering if anyone knows how to delete repeated rows.. Say for example,

   A        B       C

1  1        3       4
2  2        6       9
3  TEST            


        
5条回答
  •  南笙
    南笙 (楼主)
    2020-12-12 00:32

    I have attempted my code once again and it can work out well.. Thanks! I will share it here to answer similar questions in the future!

      Sub Macro1()
    
      Dim LastRowcheck As Long, n1 As Long, rowschecktodelete As Long
    
      LastRowcheck = Worksheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
    
      For n1 = 1 To LastRowcheck
        With Worksheets("Sheet1").Cells(n1, 1)
          If Cells(n1, 1) = Cells(n1 + 1, 1) Then
            Worksheets("Sheet1").Cells(n1, 1).Select
            Selection.EntireRow.Delete
         End If
       End With
      Next n1
    
      End Sub
    

提交回复
热议问题