LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Speed up Array Transfer to Dictionary

Hi I have a routine which checks an array with duplicate entries and tranfers
only the unique items to a dictionary. The code works fine excpet it is very
slow. Its slow because the array has to compare each of its element to every
other element in the array. If the size of the array is large, the code
slows down dramatically.

The array is called PR2 and the Dictionary is called Dict1.

Note I need all the duplicates as I use them to calculate a frequency of
occurence for each duplicate. This is why I kept the duplicate data in an
array in the first place as a dictionary cannot have duplicate keys.

Set Dict1 = New Dictionary

For t = LBound(PR2) To UBound(PR2)
If Not Dict1.Exists(PR2(t)) Then
For z = LBound(PR2) To UBound(PR2)
If z = t Then
'Do nothing as you are comparing this
'word to itself
ElseIf z < UBound(PR2) Then
If PR2(t) = PR2(z) Then
'Duplicate flagged. Don't add to
'Dictionary
dupe = dupe + 1
End If
Else
'Only add to dictionary on last
'run as dictionary can not have duplicate
'keys
Dict1.Add PR2(t), dupe
End If
Next
End If
'Reset Duplicate
dupe = 1
Next

Thanks

EM
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Improve speed of data transfer loop patrick Excel Programming 2 February 14th 08 10:04 PM
Speed of fixed array versus dynamic array Sing Excel Programming 8 November 18th 07 10:19 AM
Please Help: Transferring from Dictionary to Array Magnivy Excel Programming 2 September 2nd 06 06:13 AM
HOW TO TRANSFER AUTOCORRECT DICTIONARY TO NEW COMPUTER?? ALAN K Setting up and Configuration of Excel 1 February 17th 05 09:34 PM
Speed up performance for very big array Cool Sport Excel Programming 10 December 15th 04 09:53 AM


All times are GMT +1. The time now is 03:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"