0

在 OOo 计算中

我需要使用分配给按钮的宏将一列(仅值,而不是格式)从一张表复制到另一张表(在同一个工作表中)。

我浏览了一下,但没有发现任何重要的东西:-(

4

2 回答 2

1

好的,我可以建立答案并开始学习 OOo Basic,直到现在我才设法避免;-)

我按原样给它。

Sub UpdateThisWeek

Dim Doc As Object
Dim ThisWeek As Object
Dim Steering As Object
Dim Source As Object
Dim Target As Object
Dim Week as Integer

Doc = ThisComponent
ThisWeek = Doc.Sheets.getByName("This week")
Steering = Doc.Sheets.getByName("Steering")
Week = Steering.getCellByPosition(6,4).Value
Source = ThisWeek.getCellRangeByName("H12:H206")
Target = Steering.getCellRangeByName("M12:AU206").getCellRangeByPosition(Week-19,0,Week-19,194)

Dim i, s
For i = 0 To 194
    s = Source.getCellByPosition(0, i).Value
    If s > 0 Then
        Target.getCellByPosition(0, i).Value = s
    Else
        Target.getCellByPosition(0, i).String = ""
    End If
Next i

End Sub
于 2009-05-12T15:25:43.577 回答
1

要回答原始问题:

使用数据数组,这在大范围的单元格上会明显更快

Source = ThisWeek.getCellRangeByName("H12:H206")
source_data = Source.getDataArray()

Target = Steering.getCellRangeByName("M12:AU206").setDataArray(source_data())
于 2014-05-29T18:50:22.360 回答