How to count same cells in several columns in LibreOffice Calc?

I want to count the content (text and numbers) of same cells in several columns. is this possible? i have tried COUNTIF but i’m getting Err:510.
e.g. range A1:B40 criteria =A1:B40
Thanks a lot in advance!

Can you give a bit more detail? For example, tell us explicitly what column A, B, C etc. contains and the type of data in each column and how you want to count it. Match a certain condition? Match multiple conditions?

Hi,

COUNT() can only count cells with numbers, all cells without numbers will be ignored, to include them use COUNTA().

For you it will be:
=COUNTA(A1:B40)

This is the correct usage of COUNTIF():

=COUNTIF(Range(cells that have the data), Criteria(the IF part))

So for example, Tonight I wanted to check if Cells C2 through C151 have a Y value. To do this I placed the function:

=COUNTIF(C2:C151,"Y")

You MUST put the “” if you’re checking for a string value (words or letters). This will return the number of cells that meet the criteria in the cell the function is assigned to, in my case at this point in time, is 126.