I have an array called FileRefArr (dimmed as (1 To number_of_files, 1 To 8)) that stores information of 500-1000 text files. The (x, 2) value within the array contains an identifier. The identifier is not exclusive to each file (100 or so of the files might have the same identifier). I wrote a function to count the number of occurrences of each identifier, but I'm not sure how to gather the position of each occurrence. It needs to be dynamic, since the number of files and identifiers is always changing.
I made another array called Ident_List that stores only unique identifiers (1 - 15 unique identifiers for every 1000 files) and number of occurrences of each identifier. I was hoping to store an array of the positions in that array, but I'm not sure how to do that (see table below).
What I want to do:
UniqueIdent1, 55, Array of Positions
UniqueIdent2, 99, Array of Positions
UniqueIdent3, 8, [1,2,3,4,8,17,98,161]
...etc
Does anyone have any ideas? Would a 3-dimensional array work fine?
Code of occurrences function...
I made another array called Ident_List that stores only unique identifiers (1 - 15 unique identifiers for every 1000 files) and number of occurrences of each identifier. I was hoping to store an array of the positions in that array, but I'm not sure how to do that (see table below).
What I want to do:
UniqueIdent1, 55, Array of Positions
UniqueIdent2, 99, Array of Positions
UniqueIdent3, 8, [1,2,3,4,8,17,98,161]
...etc
Does anyone have any ideas? Would a 3-dimensional array work fine?
Code of occurrences function...
Code:
Function OccurrencesInArray(InputArray() As String, Match_Name As String) As String
Dim i As Long
Dim o_counter As Integer
Dim TempArray() As String
ReDim TempArray(1 To UBound(InputArray))
For i = LBound(InputArray) To UBound(InputArray)
TempArray(i) = InputArray(i, 2)
Next i
For i = LBound(TempArray) To UBound(TempArray)
If TempArray(i) = Match_Name Then
o_counter = o_counter + 1
End If
Next i
OccurrencesInArray = o_counter
Erase TempArray
End Function
Last edited: