ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   count the number of nonblank cells within a range (https://www.excelbanter.com/excel-programming/360957-count-number-nonblank-cells-within-range.html)

Hervinder

count the number of nonblank cells within a range
 
i want to be able to count cells within a range that are non blank or have a
value in them.

i am able to count all cells by doing

ncells = range("a1","120").cells.count

is there a similar code that will count the cells which only have a value in
them.

the only way i can think of doing this is either a loop and selecting each
cell within the range or by using the counta function within excel itself.

thank you in advance
Hervinder

JE McGimpsey

count the number of nonblank cells within a range
 
One way:

nCells = Application.CountA(Range("A1","I20"))


In article ,
Hervinder wrote:

i want to be able to count cells within a range that are non blank or have a
value in them.

i am able to count all cells by doing

ncells = range("a1","120").cells.count

is there a similar code that will count the cells which only have a value in
them.

the only way i can think of doing this is either a loop and selecting each
cell within the range or by using the counta function within excel itself.

thank you in advance
Hervinder



All times are GMT +1. The time now is 07:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com