Sam
Sam

Reputation: 3177

Count number of populated cells in range

How do I count the number of populated cells (with text/number or combinations of text+number)?

I tried =countif(A2:A2000,1=1) (with a general criteria, e.g. 1=1 always) but shows zero (0) for a text column.

Upvotes: 2

Views: 108215

Answers (4)

Varun Rajan
Varun Rajan

Reputation: 276

I think for the answer above, it should rather be

Application.WorksheetFunction.CountA(Range("A2:A2000"))

I have always faced problems while not mentioning Range, cause it considers the whole range to be as a single unit.

Upvotes: 11

user2965711
user2965711

Reputation: 77

Dim Coloumncount As Integer Coloumncount = Application.WorksheetFunction.CountA([D1:D100])'count how many filled cell in coloumn "D"

Upvotes: 0

KurtisT
KurtisT

Reputation: 81

In VBA it's WorksheetFunction.CountA("A2:A2000")

Upvotes: 5

Jüri Ruut
Jüri Ruut

Reputation: 2530

The formula is =COUNTA(A2:A2000) : non-blank cells are counted.

Upvotes: 5

Related Questions