Menu

Selasa, 15 November 2016

Memisahkan Duplikat dan data Unik dengan VBA Excel

Private Sub CommandButton1_Click()
i = 1
J = 0
k = 0
With ThisWorkbook.Sheets("Sheet2")
.[C:C,D:D,E:E].ClearContents
Do
If Application.WorksheetFunction.CountIf(.[C:C], .Cells(i, 1).Value) Then
J = J + 1
.Cells(J, 5).Value = .Cells(i, 1).Value
Else
k = k + 1
.Cells(k, 3).Value = .Cells(i, 1).Value
.Cells(k, 4).Value = Application.WorksheetFunction.CountIf(.[A:A], .Cells(k, 3).Value)
End If
i = i + 1
If .Cells(i, 1).Value = Empty Then Exit Do
Loop
End With
End Sub