Hi all,
I'm having an Excel and I want to create a list of all unique values in Column A and B and copy them to a new sheet.
This is my current Excel:
This is my code:
Sub CreateUniqueList()
Dim lastrow As Long
Dim ws As String
ws = ActiveSheet.Name
Sheets.Add.Name = "mysheet"
Sheets(ws).Range("A:B").EntireColumn.AdvancedFilter , _
Action:=xlFilterCopy, _
CopyToRange:=Sheets("mysheet").Range("A1"), _
Unique:=True
End Sub
After executing this code I get a new sheet called "mysheet" but it's empty:
What's wrong with the VBA code? Or why is this sheet empty?
I'm having an Excel and I want to create a list of all unique values in Column A and B and copy them to a new sheet.
This is my current Excel:
This is my code:
Sub CreateUniqueList()
Dim lastrow As Long
Dim ws As String
ws = ActiveSheet.Name
Sheets.Add.Name = "mysheet"
Sheets(ws).Range("A:B").EntireColumn.AdvancedFilter , _
Action:=xlFilterCopy, _
CopyToRange:=Sheets("mysheet").Range("A1"), _
Unique:=True
End Sub
After executing this code I get a new sheet called "mysheet" but it's empty:
What's wrong with the VBA code? Or why is this sheet empty?