Hi all,
I am looking for a VBA code to generate the following arrays:
Input array:
Output array:
The output array numbers the number of times the respective array input has been shown before.
Eg.
array1(1) = 12, and is the first time its showing, thus array2(1) = 1
array1(2) = 5, and is the first time its showing, thus array2(2) = 1
array1(3) = 12, and is the second time its showing, thus array2(3) = 2
array1(4) = 5, and is the second time its showing, thus array2(4) = 2
and so on so forth.
I am thinking of considering the first x elements of the array through a loop, and counting the number of occurrences of that particular element in array1 and then storing it in array2, but I am unsure of how to consider only the first x elements of an array.
Appreciate any help at all! Thank you.
I am looking for a VBA code to generate the following arrays:
Input array:
VBA Code:
array1(12 , 5 , 12 , 5 , 5 , 3 , 4 , 3 , 4)
VBA Code:
array2( 1, 1 , 2 , 2 , 3 , 1 , 1 , 2 , 2)
The output array numbers the number of times the respective array input has been shown before.
Eg.
array1(1) = 12, and is the first time its showing, thus array2(1) = 1
array1(2) = 5, and is the first time its showing, thus array2(2) = 1
array1(3) = 12, and is the second time its showing, thus array2(3) = 2
array1(4) = 5, and is the second time its showing, thus array2(4) = 2
and so on so forth.
I am thinking of considering the first x elements of the array through a loop, and counting the number of occurrences of that particular element in array1 and then storing it in array2, but I am unsure of how to consider only the first x elements of an array.
Appreciate any help at all! Thank you.