Hi,
I have two arrays of strings, called InputAlias and OutputAlias. I compare them starting from the first element in InputAlias and, when there is a match, I extract the location in OutputAlias. For example
InputAlias = (a,b,c,d,f,e)
OutputAlias = (a,d,e)
I loop starting with "a" in InputAlias and I get the location 1.
I have been using this code:
And it has been working great except when there is no match. I didn't notice this issue earlier because all the elements in OutputAlias are in InputAlias (the reverse is not true). I noticed it when I wrongly added an element in Input Alias that was not in OutputAlias.
It seems when there is no match, LocationArray takes the last value (or the value with the closest match ... not sure) and wrongly replaces OutputValue. Is it possible to modify the code to skip the element when there is no matches? Maybe add an error warning about the problem?
Thanks!
I have two arrays of strings, called InputAlias and OutputAlias. I compare them starting from the first element in InputAlias and, when there is a match, I extract the location in OutputAlias. For example
InputAlias = (a,b,c,d,f,e)
OutputAlias = (a,d,e)
I loop starting with "a" in InputAlias and I get the location 1.
I have been using this code:
Code:
For i = 0 To 10
For jj = LBound(InputAlias) To UBound(InputAlias)
If StrComp(OutputAlias(i), InputAlias(jj, 1), vbTextCompare) = 0 Then
LocationArray = jj
Exit For
End If
Next
OutputValue(i) = InputValue(LocationArray)
Next
And it has been working great except when there is no match. I didn't notice this issue earlier because all the elements in OutputAlias are in InputAlias (the reverse is not true). I noticed it when I wrongly added an element in Input Alias that was not in OutputAlias.
It seems when there is no match, LocationArray takes the last value (or the value with the closest match ... not sure) and wrongly replaces OutputValue. Is it possible to modify the code to skip the element when there is no matches? Maybe add an error warning about the problem?
Thanks!