Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Mergeing two Arrays
This will merge two zero-based arrays A1() and A2() into
zero-based array A3(). Dave Ring Sub Merge(A1(), A2(), A3()) Dim N1&, N2&, N3&, I&, J&, K& N1 = UBound(A1): N2 = UBound(A3): N3 = N1 + N2 Redim A3(0 to N3) I = 0: J = 0: K = 0 Do If A1(I) <= A2(J) Then A3(K) = A1(I): I = I + 1: K = K + 1 If I N1 Then Do A3(K) = A2(J): J = J + 1: K = K + 1 Loop Until J N2 Exit Do End If Else A3(K) = A2(J): J = J + 1: K = K + 1 If J N2 Then Do A3(K) = A1(I): I = I + 1: K = K + 1 Loop Until I N1 Exit Do End If End If Loop End Sub Paul W Smith wrote: Has anyone got any sample code for merging two sorted one dimensional arrays into one sorted new one? e.g. A1 = (2, 4, 6, 8) A2 = (2, 3, 4, 9, 10) RESULT = (2, 3, 4, 6, 8, 9, 10) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Arrays | Excel Discussion (Misc queries) | |||
Mergeing Cells | Excel Worksheet Functions | |||
mergeing cells and wrapping text | Excel Discussion (Misc queries) | |||
Mergeing two Arrays | Excel Programming | |||
Mergeing two Arrays | Excel Programming |