Search Duplicate and Result in Next Worksheet

Vgabond

Board Regular
Joined
Jul 22, 2008
Messages
197
Hi Guys

I need help to search duplicates in datas and the result will be in the next worksheet. Result will shows only one entry without anymore duplicate.

Regards
Vgabond
 
Last edited by a moderator:
@vgabond :

IF your data field(Say "agent") which may have duplicate, i suggest to creat the pivot table with the filed "agent" in row and the same in the data with count of "agent". This will provide you the agent code counts.(sort by descending and check the data).

To remove the duplicate from the main database, first sort the field "agent". Then create the temporary col next to "agent". Say "chk_field" in col "B".
Write the following formula in cell B2:
IF(A2=A1,"K"," ")( here col A has the data of agent.)
copy the formula in col B. Copy and paste the value and filter the "k" in col B. These will provide you the data those are duplicates. After deleting the filtered row, pls delete the col "B" - chk_field and you will find your data as per your requirement.

(The above can be recorded in macro too).

Share your experience.
 
Upvote 0

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
You should thank to Erik
try
Code:
Option Explicit
 
Sub copy_uniques()
'Erik Van Geit (modified by jindon)
'070605
    Sheets(2).Columns(1).Clear
    With Sheets(1)
        .Range("c1", .Range("c" & Rows.Count).End(xlUp)).Copy
        Sheets(2).Cells(1).PasteSpecial xlPastValues
        .Range("g2", .Range("g" & Rows.Count).End(xlUp)).Copy
        Sheets(2).Cells(Rows.Count).End(xlUp)(2).PasteSpecial xlPastValues
    End With
    Sheets(2).Range("a1").CurrentRegion.Resize(, 1).AdvancedFilter _
    Action:=xlFilterCopy, CopyToRange:=.Cells(1, 1), unique:=True 
End Sub

Hi Jindon

It gaves me Compile Error: Variable no defined

p/s I thank to both of ya...

Regards

Vgabond
 
Last edited:
Upvote 0
you didn't tell where the error occured, but fortunately it was easy to detect
"xlPastvalues" was a typo
quick fixed also some other things

try this
Code:
Sub copy_uniques()
'Erik Van Geit (modified by jindon) and again by Erik :-)
'070605
    Sheets(2).Columns(1).Clear
    With Sheets(1)
        .Range("c1", .Range("c" & Rows.Count).End(xlUp)).Copy
        Sheets(2).Cells(1).PasteSpecial xlPasteValues
        .Range("g2", .Range("g" & Rows.Count).End(xlUp)).Copy
        Sheets(2).Cells(Rows.Count, 1).End(xlUp)(2).PasteSpecial xlPasteValues
    End With
    With Sheets(2)
    .Range("a1").CurrentRegion.Resize(, 1).AdvancedFilter _
    Action:=xlFilterCopy, CopyToRange:=.Cells(1, 2), unique:=True
    .Columns(1).Delete
    End With
End Sub
 
Upvote 0
jindon, as always, plenty of modesty :)

Vgabond, sorry, I didn't see the second "Agent" column :cool:. Must be professional deformation, because I would never use the same label for different columns.

I had no error: it worked for me.
Jindons solution will work to my sense: if you still have an error problem, please tell us on what codeline it arises.

Hi Eric..after I change it to code which modified by Jindon, it gaves me compile error :- Variable Not Defined ..and it highlighted xlPastValues in yellow
 
Upvote 0
you didn't tell where the error occured, but fortunately it was easy to detect
"xlPastvalues" was a typo
quick fixed also some other things

try this
Code:
Sub copy_uniques()
'Erik Van Geit (modified by jindon) and again by Erik :-)
'070605
    Sheets(2).Columns(1).Clear
    With Sheets(1)
        .Range("c1", .Range("c" & Rows.Count).End(xlUp)).Copy
        Sheets(2).Cells(1).PasteSpecial xlPasteValues
        .Range("g2", .Range("g" & Rows.Count).End(xlUp)).Copy
        Sheets(2).Cells(Rows.Count, 1).End(xlUp)(2).PasteSpecial xlPasteValues
    End With
    With Sheets(2)
    .Range("a1").CurrentRegion.Resize(, 1).AdvancedFilter _
    Action:=xlFilterCopy, CopyToRange:=.Cells(1, 2), unique:=True
    .Columns(1).Delete
    End With
End Sub

Eric ......It WORKS !!!!!!! ;):ROFLMAO:

Thank you very much...........you too Jindon. Thanks a lot guys..You guys are the GREAT!
 
Upvote 0
was that a joke?
or did you ask for a walk through to create a button?

To create a button with the Forms Toolbar
Menu Display / Toolbars ==> choose Forms
click on the button-icon
drag a button on your sheet
(pressing Alt while doing this will align the button with one or some cells)
you will be asked to attach a macro to the button
(you can always set or change this rightclicking on the button)
choose the macro you want from the list
 
Upvote 0
was that a joke?
or did you ask for a walk through to create a button?

To create a button with the Forms Toolbar
Menu Display / Toolbars ==> choose Forms
click on the button-icon
drag a button on your sheet
(pressing Alt while doing this will align the button with one or some cells)
you will be asked to attach a macro to the button
(you can always set or change this rightclicking on the button)
choose the macro you want from the list

;) Thanks Eric......Got it..
 
Upvote 0

Forum statistics

Threads
1,221,586
Messages
6,160,646
Members
451,661
Latest member
hamdan17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top