View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
mm_it_it mm_it_it is offline
external usenet poster
 
Posts: 3
Default Sorted range into collection

Maybe I wrote something that is almost right:

Public Function getDistincValuesFromRange(rangeValue As String) As Collection

Dim tmpCollection As Collection
Set tmpCollection = New Collection

Dim tmpRange As Range
Dim tmpCell As Variant

'Set tmpRange = ActiveWorkbook.Sheets("DataSheet").Range("A:A")
Set tmpRange = ActiveWorkbook.Sheets("DataSheet").Range(rangeValu e)

For Each tmpCell In tmpRange
On Error Resume Next
tmpCollection.Add tmpCell.Value, tmpCell.Value
Next

tmpCollection.Sort Key1:="Key"

End Function

Unfortunately I'm still having problems with the last instruction, it
doesn't sort the collection, but it neither raise any error ...
Is it the way I use the sort method?
Thanks again


--
Nobody expects the Spanish Inquisition! Our chief weapon is
surprise...surprise and fear...fear and surprise.... Our two weapons are fear
and surprise...


"mm_it_it" wrote:

Hi everyone,
I'm working with excel 2003 and I'm developing a custom interface to
automatize some operations.
I'm using the MS office VB editor. I can't use .net framework.
I need to:
- take the values contained in an excel column
- sort values alphabetically
- remove duplicate values
- put the values in a collection.
I need to do everything "on the code side", cell values on the sheet cannot
be modified.
The requisite of the collection is not mandatory, any similar object would
be useful.
I did many test but none of them works.
Thanks in advance to everybody

--
Nobody expects the Spanish Inquisition! Our chief weapon is
surprise...surprise and fear...fear and surprise.... Our two weapons are fear
and surprise...