Remove Duplicates from Array and Retrieve Data from 2nd Array

tmcmahon74

New Member
Joined
Jun 30, 2009
Messages
14
I am trying to create a macro that will place 2 sets of data (basically Category and Category Description) into separate arrays, remove duplicates from the first array, and place the appropriate Category Description in the second array.

I have been able to accomplish placing data from the named ranges into arrays and removing the duplicates from the first array using a collection, but I haven't been able to retrieve the corresponding Category Description that goes with the Category.

A vlookup is not the best solution for me due to the fact that new Categories may be added without my knowledge, so I want to be able to handle the new data without maintaining a separate table.

Also, using the same code to remove duplicates for the Category Description may not be viable due to data errors. I have come across a few times that a category erroneously has multiple descriptions. This is a separate issue to be fixed in our data downloads, but I want to be able to take it in to account in case it happens again (the solution, right or wrong, will be to take the first description for a particular category that it comes across).

Thanks in advance for any help.

Tim
 
if using excel 2007 or later maybe this would do the job
Code:
Sub dupremove()
With Intersect(Range("A1").CurrentRegion, Range("A:F"))
    .RemoveDuplicates Columns:=Array(3, 4, 5, 6), Header:=xlYes
    .Sort Range("B1"), 1, Header:=xlYes
    .Columns(1).Delete
End With
End Sub
 
Upvote 0

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