BASIC runtime error. Sub-procedure or function procedure not defined

What I'm trying to do is to count the average of some cells on the Macro of LibreOffice Calc... By this code: REM ***** BASIC *****

Private Sub myrange()
myrange = Range("G31:G42")
Range("H45") =  WorksheetFunction.Average(myrange)

End Sub

I got the error: BASIC runtime error. Sub-procedure or function procedure not defined. What should I do?

Upvotes: 0

Views: 1835

Answers (1)

Epameinondas
Epameinondas

Reputation: 848

If you try to average the cells G31:G42 and insert the result in cell H45 then the following macro may helps you:

Private Sub myrange()
Dim Doc, myrange, sheet As Object

Doc = ThisComponent
sheet = Doc.Sheets(0)
sheet.getCellRangeByName("H45").Formula = "= AVERAGE(G31:G42)"
End Sub

Upvotes: 0

Related Questions