I am working in excel 2007, in vba.
I have a range of cells that contain various values / data. I want to exctract only the unique values/occurences and remove any duplicates.
My ideal "result" would be an array holding each unique value with the data type of that value preserved.
I have seen similar solutions using user functions, or specialized versions of the advanced filter from vba.
But my question is... which way is the best way?
and by best I mean that it fulfills these criteria:
- as fast as possible (avoiding any unnessecary looping etc)
- can accept any value types (dates, strings, numbers whatever...)
- can be fully used from vba
I have found some functions, for example:
but it seems to be written specifically to work on string values, and gives unexpected results when I pass a range of cells holding date data type.
So how should I do it?
Advanced filter? or custom function? or some other way?
regardless of which, could you please provide me with an example including code?