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
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
jindon, as always, plenty of modesty
Vgabond, sorry, I didn't see the second "Agent" column . 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.
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 thisCode: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
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