copying unique values into a new column

keeper85

New Member
Joined
Jun 10, 2011
Messages
15
Hi,

I need help with the following problem. I have a long column starting in cell AQ3 with a lot of values (where the length of the column and the values might change) and I want to copy the unique values in this column in the column next to it starting with cell AR3. I tried to record a code and slightly modify it using the advanced filter method, however, for some reason it gives me errors (it says that the AdvanceFilter method of range class failed). This is the code I have so far:

Dim TargetPos As Range
Set Target = Range("ar3")
Sheets("Report1").Range("aq3", Range("aq65536").End(xlUp)).AdvancedFilter _
Action:=xlFilterCopy, CopyToRange:=TargetPos, Unique:=True

If someone could provide me with the correction or can suggest an alternative method to Advancedfilter, I would really appreciate it.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
This works for me

Code:
Dim TargetPos As Range
With Sheets("Report1")
    Set TargetPos = .Range("ar3")
    .Range("aq3", .Range("aq65536").End(xlUp)).AdvancedFilter _
    Action:=xlFilterCopy, CopyToRange:=TargetPos, Unique:=True
End With
 
Upvote 0
I am really surprised it does not work as well. Though I noticed that in certain parts of my sheet the Advanced Filter method does not work, even if I do it manually. Can someone suggest an alternative method to copying unique values into a new column instead of AdvancedFilter, maybe some kind of a loop?
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top