Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Using duplicate data in Dictionary or Collection

Is there a way to load data strings (with some duplicates) into a container
and then use some form of .Exists and .Remove (i.e. not an array) to redefine
the container? Note I need the duplicates for calclations purposes.

I have a list of strings. I load them into a container. There are
duplicate strings. I need the duplicates as I am calculating the frequency of
their occurences. I then check the entire list for a sub list of strings
and remove these strings. Becasue I am using duplicate strings I cannot use
a collection or a dictionary as they cannot take duplicate keys. Therefore I
am using an array.

However when it comes time to removing the stings (rows) I don't have the
luxury of using .Exist booleans as I can with a dictionary object. I have to
loop through the entire array to see if the sting exists AND THEN I have find
a way to get rid of all my empty rows in the array. Probably the best way to
do this is to transfer all nonempty data from first arraty into second array
and then back to first arrray. Bit of pain

Any ideas?

Thanks

EM
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default Using duplicate data in Dictionary or Collection

On May 12, 5:25*pm, ExcelMonkey
wrote:
Is there a way to load data strings (with some duplicates) into a container
and then use some form of .Exists and .Remove (i.e. not an array) to redefine
the container? *Note I need the duplicates for calclations purposes.

I have a list of strings. *I load them into a container. *There are
duplicate strings. I need the duplicates as I am calculating the frequency of
their occurences. *I *then check the entire list for a sub list of strings
and remove these strings. *Becasue I am using duplicate strings I cannot use
a collection or a dictionary as they cannot take duplicate keys. *Therefore I
am using an array. *

However when it comes time to removing the stings (rows) I don't have the
luxury of using .Exist booleans as I can with a dictionary object. *I have to
loop through the entire array to see if the sting exists AND THEN I have find
a way to get rid of all my empty rows in the array. *Probably the best way to
do this is to transfer all nonempty data from first arraty into second array
and then back to first arrray. *Bit of pain

Any ideas?

Thanks

EM


EM

Seems like you could use a class to contain your strings. Then you
could keep a count as duplicates arise. You would have all your
frequence information available and a list of unique strings to check
against for your removal.

Ken
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Using duplicate data in Dictionary or Collection

Right. So I create a class called Thing which is effectviely my strings with
frequency data. Then I create aa class called Things (which is a collection
of Thing). I then add all my indvidual Thing ojbects to Things. Then when it
comes time to get rid of my strings, I am really just removing the invidual
Thing Objects from my Collection Things.

Does that sound right? Or have I created the same issue with the Custom
Collection by not being able to add duplicate "keys" to it?

Thanks

EM

" wrote:

On May 12, 5:25 pm, ExcelMonkey
wrote:
Is there a way to load data strings (with some duplicates) into a container
and then use some form of .Exists and .Remove (i.e. not an array) to redefine
the container? Note I need the duplicates for calclations purposes.

I have a list of strings. I load them into a container. There are
duplicate strings. I need the duplicates as I am calculating the frequency of
their occurences. I then check the entire list for a sub list of strings
and remove these strings. Becasue I am using duplicate strings I cannot use
a collection or a dictionary as they cannot take duplicate keys. Therefore I
am using an array.

However when it comes time to removing the stings (rows) I don't have the
luxury of using .Exist booleans as I can with a dictionary object. I have to
loop through the entire array to see if the sting exists AND THEN I have find
a way to get rid of all my empty rows in the array. Probably the best way to
do this is to transfer all nonempty data from first arraty into second array
and then back to first arrray. Bit of pain

Any ideas?

Thanks

EM


EM

Seems like you could use a class to contain your strings. Then you
could keep a count as duplicates arise. You would have all your
frequence information available and a list of unique strings to check
against for your removal.

Ken

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Using duplicate data in Dictionary or Collection

ExcelMonkey,

I've done this in vbScripts before using the Scripting Dictionary. As you
state, you can't have duplicate keys. The solution is to read each string
and first check if that string exists as a key in your dictionary. If not,
add the string and assign the integer 1 as the associated value. If the key
already exists, retrieve the current value associated with the key and
append the value by 1. When you've read all the strings, the values in your
Scripting Dictionary object will represent the frequency for the key
(string) its associated with.


Steve Yandl



"ExcelMonkey" wrote in message
...
Is there a way to load data strings (with some duplicates) into a
container
and then use some form of .Exists and .Remove (i.e. not an array) to
redefine
the container? Note I need the duplicates for calclations purposes.

I have a list of strings. I load them into a container. There are
duplicate strings. I need the duplicates as I am calculating the frequency
of
their occurences. I then check the entire list for a sub list of strings
and remove these strings. Becasue I am using duplicate strings I cannot
use
a collection or a dictionary as they cannot take duplicate keys.
Therefore I
am using an array.

However when it comes time to removing the stings (rows) I don't have the
luxury of using .Exist booleans as I can with a dictionary object. I have
to
loop through the entire array to see if the sting exists AND THEN I have
find
a way to get rid of all my empty rows in the array. Probably the best way
to
do this is to transfer all nonempty data from first arraty into second
array
and then back to first arrray. Bit of pain

Any ideas?

Thanks

EM



Reply
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
sorting/no duplicate scripting dictionary in Excel VBA [email protected] Excel Programming 1 October 23rd 06 10:40 PM
Enumerating PivotItems collection fails to display duplicate values kirk Excel Programming 2 October 17th 06 09:01 AM
Collection VS Scripting.Dictionary Tetsuya Oguma Excel Programming 1 October 16th 06 09:49 AM
Limitation of collection and dictionary datatype iamrajy[_7_] Excel Programming 1 January 27th 06 04:58 PM
Linking MS dictionary as data into Excel Yabbadoo Excel Programming 2 March 30th 05 11:40 PM


All times are GMT +1. The time now is 04:15 PM.

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"