In libreoffice there's no built-in way to concatenate the text of all cells in a range together (i.e. to create a condensed CSV-style list. I call this CSV-ifing).
This BASIC macro accomplishes it (simply type e.g. "=CSVIfyArray(A1:C10)" after creating the macro as follows in "My Macros & Dialogs/Standard/Module1)
Function CSVifyArray(pArray(),OPTIONAL sep as String,OPTIONAL ColFirst as Boolean) as String
IF IsMissing (sep) THEN sep=","
IF IsMissing (ColFirst) THEN ColFirst=FALSE
Dim i as Long, j as Long, ib as Long, ie as Long, jb as Long, je as Long
Dim rText as String
Dim item as String
Dim addStr as String
if NOT(ColFirst) THEN
ib = Lbound(pArray(),1) REM i holds row indexes
ie = Ubound(pArray(),1)
jb = Lbound(pArray(),2) REM j holds column indexes
je = Ubound(pArray(),2)
ELSE REM PivotTable-like implementation
jb = Lbound(pArray(),1) REM j will hold row indexes
je = Ubound(pArray(),1)
ib = Lbound(pArray(),2) REM i holds column indexes
ie = Ubound(pArray(),2)
ENDIF
rText = ""
For i = ib to ie
For j = jb to je
IF NOT(ColFirst) THEN item = CStr(pArray(i,j)) ELSE item = CStr(pArray(j,i))
IF (item = "0") THEN item = "" REM this was so blank cells do not contribute. If "0" is a legitimate value for you, you may need additional (or less) logic here
IF (rText <> "") THEN addStr = sep + item ELSE addStr = item
IF (item <> "") THEN rText = rText + addStr
Next j
Next i
CSVifyArray = rText
End Function REM CSVifyArray
Implementation expanded from
http://en.libreofficeforum.org/node/6415 (specifically post #8)
post edited by pagelm - 2014/04/24 10:44:20