Ask Your Question
0

How can I distinguish a cell that it is blank or not while inside a user-defined function in Calc Basic? [closed]

asked 2013-11-03 22:25:57 +0200

Shayan.To gravatar image

updated 2013-11-04 07:11:33 +0200

oweng gravatar image

How can I distinguish a cell that it is blank or not while inside a user-defined function in Calc Basic? For example if I want to write an "Average" function to work just like the built-in one, I'll try to do something like this:

Public Function AverageS(A)
    Res = 0
    N = 0
    For i = LBound(A, 1) To UBound(A, 1)
        For j = LBound(A, 2) To UBound(A, 2)
            If Not IsEmpty(A(i, j)) Then
                Res = Res + A(i, j)
                N = N + 1
            End If
        Next
    Next
    AverageS = Res / N
End Function

But NotEmpty does not do what I want it to. What should I do?

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by Alex Kemp
close date 2015-11-12 20:33:02.706105

1 Answer

Sort by » oldest newest most voted
0

answered 2013-11-04 07:09:27 +0200

oweng gravatar image

From Andrew Pitonyak's OpenOffice.org Macros Explained 3rd Edition r523 guide (p. 470, above Listing 412):

Use the method queryContentCells(CellFlags) to obtain a list of all cells in a range that are not empty. The CellFlags argument is set to return all cells that contain a value, string, formula, or date/time.

The indicated listing provides an example of required code.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-11-03 22:25:57 +0200

Seen: 2,613 times

Last updated: Nov 04 '13