Remove Duplicate Cells in a Row

后端 未结 4 2092
醉酒成梦
醉酒成梦 2021-01-16 09:04

Just to clarify : I don\'t want to remove duplicates rows, I want to remove Duplicate Cells within a row

So here\'s a classic address table, and in some row there\'s

4条回答
  •  佛祖请我去吃肉
    2021-01-16 09:47

    In your case, the duplicates are adjacent. To clear duplicates in either a single column or single row for this special case:

    Sub qwerty()
        Dim r As Range, nR As Long
        Set r = Intersect(Cells(13, 1).EntireRow, ActiveSheet.UsedRange)
        nR = r.Count
        For i = nR To 2 Step -1
            If r(i) = r(i - 1) Then
                r(i) = ""
            End If
        Next i
    End Sub
    

    This code is an example for row #13

提交回复
热议问题