Assigning Macro to a push buttomn

Hi All,

I’m trying to assign a macro to a push button on a LibreOffice 5 spreadsheet. I created or recorded the macro in LibreOffice 5 Writer, saved it. But when I tried to assign it to a push button in a LibreOffice 5 spreadsheet, the macro is not there. This macro was created originally in a MS Excel spreadsheet. I want this macro to work in LibreOffice 5 spreadsheet. Here is the macro:

---------------------------------------------------------------------------
Sub Button2_Click()
Worksheets("Calculations") .Range("A2:B70") .Calculate
With Worksheets("Draw")
	Range("C7") .Calculate
	Range("E7") .Calculate
	Range("G7") .Calculate
	Range("I7") .Calculate
	Range("K7") .Calculate
	Range("M7") .Calculate
End With

End Sub
------------------------------------------------------------------------

Thank you.

Where did you save the Macro? Did you save the Macro text as a Writer document or as a Macro in the Writer document Macros?

Your macro can be much shorter. There is no need to specify the address of each cell to calculate. Just say, “Calculate me everything”

Sub myButton_Click() 
	ThisComponent.calculateAll()
End Sub

(You may give the macro a name you like - not only onButton2_click)

And assign this macro to your button