Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This probably doesn't apply to your situation, but **IF** your A1, A2 and
Result arrays are **ALL** declared as being String arrays, you can perform the combining of them in a single line of code... Result = Split(Join(A1, Chr(1)) & Chr(1) & Join(A2, Chr(1)), Chr(1)) The resulting Result array will always be zero-based no matter what your Option Base setting is (the Split function always produces zero-based arrays). But remember, the above single line of code applies only if the arrays are declared as Strings. For example... Sub Test Dim A1() As String Dim A2() As String Dim Result() As String A1 = Split("1 2 3") A2 = Split("4 5 6 7 8") Result = Split(Join(A1, Chr(1)) & Chr(1) & Join(A2, Chr(1)), Chr(1)) Debug.Print UBound(Result) End Sub Note that in use, the elements of Result can still be used in calculations as VB's behind-the-scenes automatic coercion would turn the numerical String values into real numbers in order to perform the calculations. -- Rick (MVP - Excel) "Georg" wrote in message ... How do I combine two one-dimensional arrays to one new one-dimensional array? E.g. if A1 is one-dimensional (3, 12, 8) and A2 is one-dimensional (6, 1, 0, 9) I want the resulting array to be (3, 12, 8, 6, 1, 0, 9). Thanks for help! Georg |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Combine Two Arrays Into One. Tough. | Excel Worksheet Functions | |||
Combine Two Similar Arrays | Excel Worksheet Functions | |||
Function To Combine two 3-D arrays | Excel Programming | |||
Trouble with arrays (transferring values between two arrays) | Excel Programming | |||
Arrays - declaration, adding values to arrays and calculation | Excel Programming |