View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Mika Oukka Mika Oukka is offline
external usenet poster
 
Posts: 6
Default need list of unique values from array in memory

Hi,

Try the advanced filter command to generate the list of the unique values of
a field.

Range("F2:F10").AdvancedFilter Action:=xlFilterCopy,
CopyToRange:=Range( _
"H2"), Unique:=True

Mika Oukka

"KR" wrote in message
...
I'm working on a project, where I have several thousand records in an

excel
sheet (each has 30+ columns of data). I'm doing various data

manipulations,
and all is going well so far.

However, my co-worker/customer has asked for a new report, with the data
segmented by the person who is responsible for each record. So, I have

maybe
less than 100 people that repeat throughout my thousands of records. To
dynamically keep my code working, I need to pull a list of all responsible
people from the data itself. So, I'm looking for a way to identify each
"new" name as I cycle through the list.

My approach is to go through each record and compare the name to a shorter
list of the names I've already found, e.g.

for i= 1 to 5000
tempName = MyArray(i,14) 'get the name for that record
for p= 1 to 100 'my list of unique names
if tempName = FoundNames(p) then
exit for 'if I find the name, just
else
FoundName = False
end if
next
If FoundName = False then
FoundNamesCount = FoundNamesCount + 1
FoundNames(FoundNamesCount) = tempName
End if
next

But I'm thinking there must be a better (and faster) way....
Suggestions?

Thanks,
Keith
--
The enclosed questions or comments are entirely mine and don't represent

the
thoughts, views, or policy of my employer. Any errors or omissions are my
own.