Ask Your Question

From two arrays to one arrays

asked 2017-02-17 16:47:06 +0200

Fede gravatar image

Hello! if I would like to obtain from two array: A = [a b c] B = [d e f] the following array C = [a b c d e f] there is a istruction to unite the arrays A and B?

Thank you in advance

Good life!


edit retag flag offensive close merge delete


I didn't tell you that I use StarBasic

Fede gravatar imageFede ( 2017-02-18 09:14:51 +0200 )edit

3 Answers

Sort by » oldest newest most voted

answered 2017-02-17 17:28:07 +0200

updated 2017-02-18 09:46:07 +0200

See tilde (~) operator. E.g.: =SUM(A1:A3~C4:C6)

Cannot be used in Data->Validity.

EDIT: Since you need a BASIC function, you may use this:

Function UnionArrays (Arr1, Arr2)
' Expects two 1-dimensional arrays
    Dim result
    result = Arr1
    ReDim Preserve result(UBound(Arr1)+UBound(Arr2)-LBound(Arr2)+1)
    Dim i As Integer
    i = UBound(Arr1)+1
    Dim n As Integer
    For n=LBound(Arr2) To UBound(Arr2)
        result(i) = Arr2(n)
        i = i+1
    Next n
    UnionArrays = result
End Function
edit flag offensive delete link more


I'm sorry, I didn't tell you that I use Starbasic

Fede gravatar imageFede ( 2017-02-18 09:12:01 +0200 )edit

Thank You Mike :D, Good Life

Fede gravatar imageFede ( 2017-02-18 09:46:02 +0200 )edit

answered 2017-02-17 17:34:27 +0200

karolus gravatar image


It's easy as pie!


edit flag offensive delete link more


Now that I'm thinking about it, OP does make 3 arrays (or lists, as Python, pictured above, calls them) which is using same syntax some languages use, and I don't remember seeing arrays made that way in Calc. I could be wrong, though. Python does make many things much easier than any other language AFAIK.

rautamiekka gravatar imagerautamiekka ( 2017-02-17 18:32:26 +0200 )edit

I didn't tell you that I use StarBasic sorry

Fede gravatar imageFede ( 2017-02-18 09:13:40 +0200 )edit

answered 2017-02-18 17:51:08 +0200

pierre-yves samyn gravatar image


a = array("a","b","c")
b = array("d","e","f")

c = split(join(a, ",") & "," & join(b, ","), ",")


edit flag offensive delete link more



works only with strings inside array, and maybe partielly with integers or floats… python works with any objects inside lists

karolus gravatar imagekarolus ( 2017-02-18 20:42:25 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-02-17 16:47:06 +0200

Seen: 243 times

Last updated: Feb 18 '17