Open Office Spreadsheet(Calc)-用定界符连接文本单元格 [英] Open Office Spreadsheet (Calc) - Concatenate text cells with delimiters
问题描述
我正在使用Open Office的电子表格程序,并试图将多个文本单元格与分隔符连接在一起.例如,假设我有以下单元格:
I am using Open Office's spreadsheet program and am trying to concatenate several text cells together with delimeters. For example, suppose I have the cells below:
+--------+
| cell 1 |
+--------+
| cell 2 |
+--------+
| cell 3 |
+--------+
| cell 4 |
+--------+
| cell 5 |
+--------+
我想用定界符将它们连接起来,以便结果在这样的一个单元格中:
I would like to concatenate them with delimiters so that the result is in one cell like this one:
+----------------------------------------------+
| (cell 1),(cell 2),(cell 3),(cell 4),(cell 5) |
+----------------------------------------------+
我的第一个想法是尝试创建一个宏之类的东西,但是我不认为开放式办公室支持这些宏.有什么想法吗?
My first thought was to try and make a macro or something, but I don't think open office supports those. Any ideas?
推荐答案
好吧,经过更多的搜索和实验之后,我发现您可以在calc中创建自己的函数.这是我做的功能,可以实现我想要的功能:
Well, after a lot more searching and experimenting, I found you can make your own functions in calc. This is a function I made that does what I want:
Function STRCONCAT(range)
Dim Row, Col As Integer
Dim Result As String
Dim Temp As String
Result = ""
Temp = ""
If NOT IsMissing(range) Then
If NOT IsArray(range) Then
Result = "(" & range & ")"
Else
For Row = LBound(range, 1) To UBound(range, 1)
For Col = LBound(range, 2) To UBound(range, 2)
Temp = range(Row, Col)
Temp = Trim(Temp)
If range(Row, Col) <> 0 AND Len(Temp) <> 0 Then
If(NOT (Row = 1 AND Col = 1)) Then Result = Result & ", "
Result = Result & "(" & range(Row, Col) & ") "
End If
Next
Next
End If
End If
STRCONCAT = Result
End Function
这篇关于Open Office Spreadsheet(Calc)-用定界符连接文本单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!