Link to home
Start Free TrialLog in
Avatar of xenium
xenium

asked on

Appending a constant to an array in google sheets

hi,
This should be easy. In google sheets, I have an array in columns A & B as follows:

Ref      Desc
1      one
2      two
3      three
4      four
5      five

Example: https://docs.google.com/spreadsheets/d/1OVwUpodKWxgEsUuLr4wW1K_srW90ZjgvvMoZwmt1fdQ

I can copy this array by using formula ={A:B}

How can I append a constant value, eg 'mysource' so that the output is:

Ref      Desc      mysource
1      one      mysource
2      two      mysource
3      three      mysource
4      four      mysource
5      five      mysource

Thanks
Avatar of xenium
xenium

ASKER

This works, but if there's anything neater that'd be great:

={array_constrain(A:B,counta({A:A}),2),transpose(split(rept("mysource,",counta({A:A})),","))}

This method requires that column A is fully populated.
Avatar of xenium

ASKER

Here's another botch that works.. is this as good as it gets?

=ARRAYFORMULA({A1:B6, "mysource" & LEFT(A1:A6,0) })
ASKER CERTIFIED SOLUTION
Avatar of xenium
xenium

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of xenium

ASKER

Reason for choosing own solution: it works, and no other solutions were forthcoming.