OpenOffice.org: Macro Help

In OOo Calc

I need to copy a column ( values only , not format) from one sheet to another (on the same worksheet) using a macro assigned to a button.

I have been around a bit but found nothing: - (

0


a source to share


2 answers


To answer the original question:

use an array of data that will be significantly faster on large ranges of cells



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

Target = Steering.getCellRangeByName("M12:AU206").setDataArray(source_data())

      

+1


a source


Ok, I could build an answer and start learning OOo Basic, which I had previously managed to avoid -

I give it as it is.



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

      

+1


a source







All Articles