K
KR
I am cycling through some larger multidimensional arrays to find records
that match certain criteria. When I find a match, I copy a row of data to a
smaller array, which ultimately populates a row in my spreadsheet (after I
find all the matches, I add them to the target cell with a chr(10) between
each, to put each match on a new "row" within the cell).
I've run into a problem with duplicate matches, which results in my row
having duplicate data in it. I think I know how to address this, I'm just
not sure of the syntax to make it work.
Assuming I will never have more than 10 good (non-duplicate) matches, and I
do have a unique field to compare, I was thinking of adding a new
one-dimensional array and clearing it between excel rows. Each time I find
an entry that matches my criteria, I would just use the match function to
see if that value was already in the one dimensional array, and if so, skip
to the next match (if it isn't in the 1-D array, add it as normal).
So I've put some code below, but it returns a position or N/A. What is the
best way to translate that into a boolean so I can use it in my IF
statement?
'--------------------------------------------------------------
Dim CompareArray(1 to 10)
Dim CompareItem as String
Dim FoundDuplicate as Boolean
'do stuff until a match is found
FoundMatch = Excel.worksheetfunction.Match(CompareItem, CompareArray,0)
'how do I translate FoundMatch (integer or N/A) into FoundDuplicate Boolean?
If FoundDuplicate = False then
'add it to my larger data array
End if
'---------------------------------------------------------------
that match certain criteria. When I find a match, I copy a row of data to a
smaller array, which ultimately populates a row in my spreadsheet (after I
find all the matches, I add them to the target cell with a chr(10) between
each, to put each match on a new "row" within the cell).
I've run into a problem with duplicate matches, which results in my row
having duplicate data in it. I think I know how to address this, I'm just
not sure of the syntax to make it work.
Assuming I will never have more than 10 good (non-duplicate) matches, and I
do have a unique field to compare, I was thinking of adding a new
one-dimensional array and clearing it between excel rows. Each time I find
an entry that matches my criteria, I would just use the match function to
see if that value was already in the one dimensional array, and if so, skip
to the next match (if it isn't in the 1-D array, add it as normal).
So I've put some code below, but it returns a position or N/A. What is the
best way to translate that into a boolean so I can use it in my IF
statement?
'--------------------------------------------------------------
Dim CompareArray(1 to 10)
Dim CompareItem as String
Dim FoundDuplicate as Boolean
'do stuff until a match is found
FoundMatch = Excel.worksheetfunction.Match(CompareItem, CompareArray,0)
'how do I translate FoundMatch (integer or N/A) into FoundDuplicate Boolean?
If FoundDuplicate = False then
'add it to my larger data array
End if
'---------------------------------------------------------------