I have an array with multiple duplicates. I'm trying to write code that will produce a second array that contains the indexes of all of the elements in the first array that equal a look up value.
For example, I have this array:
1
1
1
2
2
2
2
2
3
3
4
5
6
6
7
I want a second array that will return the indexes of the number 6.
This is the code that I have right now.
Sub test()
Dim look_up As Integer
Dim id_ar As Variant
Dim index_ar As Variant
look_up = 6
id_ar = Range("A1:A16").Value
index_ar = Application.Match(id_ar, look_up, True)
End Sub
I want this to result in an array like this:
13
14
But it just returns a bunch of '#N/A's
lookupinstead oflook_up. Is that correct in the code as well?