Greetings!
I'm starting to experiment with arrays to expand my vba proficiency and decided to see if I could use an array to count the number of instances of a bunch of entries in a list. This obviously could then be used to show duplicates or unique values etc. etc.
I know there are likely more efficient ways to do it - it's not really about the end goal but more about figuring out how to use arrays!
Anyhow, I have the following code:
This is what I get from th![]()
Please Login or Register to view this content.
0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 0 Number of instances of 0: 0 7 Number of instances of 7: 1
So, for some reason it only remembers the last entry to the table - which is the 7. Everything else seems to get forgotten along the way.
What am I doing wrong, and do you have any generic tips for dealing with arrays where I'm going horribly wrong? I know it's inefficient to keep redefining the array - could I possibly set the array size from the start to be the total number of entries in the sample I'm analysing (which obviously would be the max number of inputs if there were zero duplicates) and then resize it smaller to match the number of actual entries to the array?
Any suggestions would be appreciated!
Thanks,
Lady Marmalade
Bookmarks