2

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.

Community
  • 1
  • 1
Sam
  • 3,067
  • 19
  • 53
  • 55

4 Answers4

11

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.

Lance Roberts
  • 22,383
  • 32
  • 112
  • 130
Varun Rajan
  • 276
  • 2
  • 11
5

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

Jüri Ruut
  • 2,500
  • 17
  • 20
5

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

KurtisT
  • 81
  • 1
  • 7
0

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

user2965711
  • 77
  • 1
  • 9