Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I concatenate cells and add extra text?

I'm very new to Calc but a relative veteran with Excel. Unfortunately I don't have the latter available to me. I'm attempting to create a new cell inline with the data I need to use like the below

AF    Afghanistan
AL    Albania
DZ    Algeria

with an output in Column C like this

<option value="AF">Afghanistan</option>

I've tried to use the CONCATENATE function to no avail. Could someone point me in the right direction on how to achieve this in OpenOffice Calc (Version 3).

Thanks

like image 653
David Barker Avatar asked Mar 28 '12 13:03

David Barker


People also ask

How do you add text after concatenate?

The easiest way to add a text string to a cell is to use an ampersand character (&), which is the concatenation operator in Excel.

How do I add multiple text in Excel?

You can put multiple lines in a cell with pressing Alt + Enter keys simultaneously while entering texts. Pressing the Alt + Enter keys simultaneously helps you separate texts with different lines in one cell. With this shortcut key, you can split the cell contents into multiple lines at any position as you need.


1 Answers

I suppose it's a problem of escaping the quotes, since they delimit the "extra strings", too. Anyway, it should work with CONCATENATE, using this formula:

=CONCATENATE("<option value=""";A1;""">";B1;"</option>")

EDIT:

Sorry, every time messing up argument separators (with german l11n, semicolons instead of commata are used...) With an english (US) localisation, you need this version:

=CONCATENATE("<option value=""",A1,""">",B1,"</option>")

If doubling the qoutes around the first cell reference doesn't work, try to replace it with CHAR(34) (the decimal ASCII code for double quotes is 34, while 22 would be the hex value):

=CONCATENATE("<option value=",CHAR(34),A1,CHAR(34),">",B1,"</option>")
like image 112
tohuwawohu Avatar answered Oct 24 '22 03:10

tohuwawohu