Function ComputeAverage(firstRow As Long, lastRow As Long) As Double The aim of this function is to calculate the average of a section of data in Column AFor example, a call of ComputeAverage(4,10) in your OO Basic program should return the average of the cells from A4 to A10You can make use of the constant DATA_COL (=1) in this function to refer to Column AThe first input firstRow is the row number of the starting rowThe second input lastRow is the row number of the last row

Title Edited. A descriptive title for posts helps others who are searching for solutions and increases the chances of a reply (Hagar, Moderator).

Last edited by axljerry123 on Tue Apr 18, 2017 3:12 pm, edited 1 time in total.

Do you know anything about the API functions? (You must use them to control the calc doc/sheet/cells).

You must get the active Calc document (Thiscomponent), and then you must get the desired Sheet (by number, by name, or the actually displayed (Current selection...) Then you can get the cells by coordinates and the numeric values of the cells. Summarize them, and divide the result by the number of the rows (/lastrow-firstrow)

And what about the empty cells? They will represent a zero value, and it increases the divider. Do you need use them in the average value?

Tibor Kovacs, Hungary; LibreOffice4.4.7 on Win7x64Prof.And the portable versions: LO3.3.0-LO5.4.1 and AOO4.1.3 Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.