在excel中列出几行:
row1: header1 header2 header3
row2: A1 B1 C1
row3: A2 B2 C2
row4: A2 B3 C2
如何根据标题1的唯一性约束删除重复行。
即。我只想返回最后一行。
E.g。删除row3并保留row4
答案 0 :(得分:0)
试用此代码,将sheet7替换为您的工作表;
Dim x As String 'place holder for column A data
Dim rc As Long 'row counter
x = Sheet7.Range("A2").Value 'get 1st value
rc = 3 'initialize with next row
Do While x <> "" 'search until you encounter a blank row
If x = Sheet7.Range("A" & rc).Value Then
Sheet7.Range(rc & ":" & rc).Delete
Else
x = Sheet7.Range("A" & rc)
rc = rc + 1
End If
Loop