Re: To declare or not to declare

From: keepITcool (xrrcvgpbby_at_puryyb.ay)
Date: 10/29/04


Date: Fri, 29 Oct 2004 14:49:20 -0700


Stephen..
yep that makes sense to me..<g>

I saw that you've finished your new book
Professional Excel Development..

Pity I'll have to wait till FEB 4th for it's release

I've just run a few tests:

(For the purpose of finding unique items)

the Collection and the Dictionary
add items at practically the same speed.

One advantage of using a Dictionary would be that
the Dictionary can return a 0based array, (either items or keys)
whereas for the dictionary this array must created.

IF you need a 1 dimensional array of unique items
the dictionary is up to 50% faster than the collection.
(plus you have CaseSensitivity!)
======================================================

For the dictionary: on error resume next
works slightly faster then using .Exists(key)
before adding the itm.

tests done with a latebound dictionary

If you DONT need to return an array.. and prefer to "keep" the object..
the dictionary has a few other advantages like being able to CHANGE the
key.

Does it have any DISADVANTAGE?

1 I've heard that some companies disable scripting...
  
2 ??

keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >

Stephen Bullen <stephen@oaltd.co.uk> wrote:

> Hi KeepITcool,
>
>> compensating for the performance loss of creating the non native
>> dictionary.
>
> FWIW, I don't think either the Collection or the Dictionary are
> 'native', so there's no performance loss. The Collection object is
> provided by the VBA library that our projects reference, while the
> Dictionary object is provided by the Scripting library that our
> projects (can) reference. The only difference is that the VBA library
> is already referenced for us by default in our projects.
>
> Regards
>
> Stephen Bullen
> Microsoft MVP - Excel
> www.oaltd.co.uk
>
>
>



Relevant Pages

  • Re: Looking for a function that will count the first instance of a
    ... are four occurrences of Bob in the array. ... The item that repeats 4 times sums to 1. ... sum of these values becomes the count of unique items. ... blanks to be counted as a unique item. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Looking for a function that will count the first instance of a
    ... are four occurrences of Bob in the array. ... sum of these values becomes the count of unique items. ... The reason for the error is blank cells in the full range A1:A20. ... blanks to be counted as a unique item. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Looking for a function that will count the first instance of a
    ... are four occurrences of Bob in the array. ... sum of these values becomes the count of unique items. ... blanks to be counted as a unique item. ...
    (microsoft.public.excel.worksheet.functions)
  • RE: unique item array
    ... >Hi Boris ... >should this apply for a mixture of data types (numeric ... and by virtue of the way this array ... >> any unused cells blank (if there were less unique items ...
    (microsoft.public.excel.misc)