1

我尝试将某些单元格的格式化内容与公式连接起来。
因为我看不到用纯公式解决它的方法,所以我添加了一些基本代码。

但我无法弄清楚如何从单个单元格中访问格式化的文本值。
似乎 oCell 不是单元格对象,而只是单元格内容。

我该如何改变这个,所以我可以使用像 oCell.Text 或 oCell.String ...

Function StringSumme(oCellRange )
    dim result as String
    dim nRow as Integer

    result = ""
   For nRow = LBound( oCellRange, 1) To UBound( oCellRange, 1 )
        For nCol = LBound( oCellRange, 2) To UBound( oCellRange, 2 )
            oCell=oCellRange(nRow,1)
            result = result + oCell
        Next 
    Next 
    StringSumme = result 
End Function

在 Excel 中这个工作

Function StringSumme(bezug As Range) As String
    Dim txt As String
    Dim ce As Range

    txt = ""
    For Each ce In bezug.Cells
        txt = txt & ce.Text
    Next
    StringSumme = txt
End Function
4

1 回答 1

1

杰布

我想我现在明白你的问题了。

当你输入这个

Function StringSumme(oCellRange)

oCellRange 不是范围。它是一个正在传递的数组。因此 oCell 不是单元格对象,而是您猜对的单元格内容。

您可能希望将其更改为类似

oCell = Sheet.getCellByPosition(X, Y)

然后使用 oCell.Value

有趣的阅​​读

http://wiki.services.openoffice.org/wiki/Documentation/BASIC_Guide/Cells_and_Ranges

于 2012-02-24T06:49:10.100 回答