Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Marston
I have two arrays: arr1 and arr2, both are two dimensional arr1(n,1) holds the string values I need to match and I need to match it within the string values of arr2(m,1). Both arr1 and arr2 are sorted by the first column. All of the values within arr1 are within arr2 at least once and sometimes more than once. In both cases, there is at least 1 if not more situations where the value of arr1(n,1) or arr2(m,1) are equal to "000" - and they generally make up a large section of both arr1 and arr2 and in both cases, I don't need to work on either array elements when they hold this value (e.g. I'd like to skip them) As they're both sorted with arr1 being a unique list, I'd loop through them both in a single pass (untested): Dim lIdx1 As Long Dim lIdx2 As Long lIdx1 = LBound(arr1) lIdx2 = LBound(arr2) Do Until lIdx1 Ubound(arr1) Or lIdx2 Ubound(arr2) 'Compare the two array items Select Case StrComp(arr1(lIdx1,1), arr2(lIdx2,1)) Case 0 'They're the same If arr1(lIdx1,1) < "000" Then 'Process them End If 'Go on to the next in arr2 lIdx2 = lIdx2 + 1 Case 1 'arr1 arr2, so move to next in arr2 lIdx2 = lIdx2 + 1 Case -1 'arr1 < arr2, so move to next in arr1 lIdx1 = lIdx1 +1 End Select Loop Regards Stephen Bullen Microsoft MVP - Excel www.BMSLtd.ie |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
vlookup - find an alternative approximate match | Excel Worksheet Functions | |||
Alternative add-on application to VLOOKUPS command? | Excel Discussion (Misc queries) | |||
application.match | Excel Discussion (Misc queries) | |||
Application.Match | Excel Programming | |||
Application.Match | Excel Programming |