View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
a.riva@UCL a.riva@UCL is offline
external usenet poster
 
Posts: 20
Default Counting number of occurrences.

Thanks for all the suggestions!

Now I have an other question...

I have my usual option-based-1 array1 in VBA, which contains x
numbers. Some of them are repeated. What I would like to do is
creating an other option-based-1 array, let's call it array2, which
contains the numbers of occurrences of each of the repeated elements
of array1 within array1... I'm struggling to find a solution...

For example:

option-based-1 array1 is (1, 2, 4, 6, 5, 4, 7, 2, 3, 2, 3) -- I
cannot sort the array.

I think that the procedure should do the following operation: it
detects how many items are repeated in "array1", and for each of this
repeated items stores in a new array "array2" a number corresponding
to the number of its occurrences.

For example, in array1 the procedure detects that there are n=3 items
which occur more than once (they are "2", "4" and "3"). Then it ReDims
array2 (1 to n), and for i=1 to n it gives to array2(i) the values of:

i=1 -- array2(1) = 3 (occurrences of "2"),
i=2 -- array2(2) = 2 (occurrences of "4"),
i=3 -- array2(3) = 2 (occurrences of "3").

Can somebody help me?

Thanks in advance :-)

Antonio.