Change a code to add another coloumn

shadow12345

Well-known Member
Joined
May 10, 2004
Messages
1,238
Hi,

I found this code on here which works great



Code:
Sub copyunique()
    Dim Sh1 As Worksheet
    Dim Rng As Range
    Dim Sh2 As Worksheet
    Set Sh1 = Worksheets("Sheet2")
    Set Rng = Sh1.Range("i1:i" & Sh1.Range("i65536").End(xlUp).Row)
    Set Sh2 = Worksheets("Sheet4")
    Rng.Cells(1, 1).Copy Sh2.Cells(1, 1)
    Rng.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Sh2.Range("a1"), Unique:=True
End Sub

It copies the unique's from one coloumn to another sheet, my question is how can i take the unique from two coloumns.

Any thoughts ? :rolleyes:
 

Some videos you may like

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

jimboy

Well-known Member
Joined
Apr 11, 2002
Messages
2,314
Add these two lines at the end;

Code:
    Set Rng = Sh1.Range("A1:A" & Sh1.Range("A65536").End(xlUp).Row)
    Rng.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Sh2.Range("B1"), Unique:=True
 

Watch MrExcel Video

Forum statistics

Threads
1,118,452
Messages
5,572,209
Members
412,448
Latest member
ManuW
Top