Solution to Find and move the duplicate values in another sheet

Vikas Verma's picture

Find and move the duplicate values in another sheet....

Before using the below mentioned code please use conditional formatting with =COUNTIF($A$1:A1,A1)>1 formula there after this code will work.

Hope it will help you...

Sub test()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Dim rng As Range
Dim cell As Range

Set rng = Application.InputBox("Select a range", Type:=8)
j = 1
For Each cell In rng

If cell.DisplayFormat.Interior.Color <> 16777215 Then
rcount = Sheets(2).Cells(Rows.Count, 1).End(xlUp).Row
cell.Cut Destination:=Sheets(2).Range("A" & j)
j = j + 1
End If

Next
rng.SpecialCells(xlCellTypeBlanks).Select
Selection.Delete Shift:=xlUp
Range("A1").Select

Application.DisplayAlerts = True
Application.ScreenUpdating = True

End Sub

Thanks & regards,
Vikas Verma

AttachmentSize
Find and move the duplicate values in another sheet.xlsm18.27 KB