Unique Filter Macro not working correctly

J

Jay

The folloiwng macro is intended to look at a list of numbers in column "M"
and copy unique records only to column "B".
But I'm still getting duplication in column "B".

Macro:
Sub Macro1()

' copy unique Work Order numbers to columb "B"
Range("M6:M200").AdvancedFilter Action:=xlFilterCopy,
CopyToRange:=Range( _
"B6"), Unique:=True

End Sub

column "M"
73369
73369
73369
75817
75817

results in column "B"
73369
73369
75817
 
N

Nigel

Check you data in column M, you probably have spaces at the beginning or end
of entries causing it to appear duplicated.

Use Trim to remove leading and trailing spacers
 
J

Jay

That's what i suspected at first.
But when I manually type the values in (witn no leading or trailing
spacers), I get the same results.
 
S

sdutta

This command requires a column header. You should include the column header
for column M in the source range as well as the copy_to range.
Assuming your header for M is in M5 it will put the header in B5 followed by
the unique results under it.

Range("M5:M200").AdvancedFilter Action:=xlFilterCopy,
CopyToRange:=Range( _
"B5"), Unique:=True
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top