开发者

Easiest Way to Find and Remove Duplicates?

I have two columns filled with data in an Excel spreadsheet:

Column 1:
A
B
C
D

Column 2:
C
D
E
F
G

Desired Data: A,B,C,D,E,F,G (not A,B,C,D,C,D,E,F,G)

I want to combine the two columns, and re开发者_如何学JAVAmove any duplicates. I'm coming from a C# word, so my understanding of VBA is limited. I know I could create an array with the dimension of dimension(column1)+dimension(column2), then do some duplicate removal (is there one built in?), or something like that.

Any guidance would be appreciated, thanks!


Use the following to do the processing...and just call it as you would any other function or subroutine.

Sub RemoveDupes()

    'Add extra Column, "A" becomes "B"
    Columns(1).EntireColumn.Insert

    'Filter out duplicates and copy unique list to "A"
    Range("B1", Range("B65536").End(xlUp)).AdvancedFilter _
        Action:=xlFilterCopy, CopyToRange:=Range("A1"), Unique:=True

    'Add extra Column, "B" becomes "A"
    Columns(2).EntireColumn.Delete

End Sub

Then just join and sort the results from each column :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜