Count number of columns with value


I have 3rows x13 columns with the following data:

1 2 3 4 5 6 7 8 9 10 11 12

1 2 3 4

1 5 6 7 8


Usually, I use count (A1 to A12), count (B1:B12) and  count (c1to C12) into 3 cells and use anothe cell to determine the max among the 3 formula to get 12  evengthough the total column =13. If there another way to do this with a single line of code?

8 Replies



I may have laid my spreadsheet out differently (in rows), but a single formula is quite easy:




if you wanted to get the largest sum of the three rows, just change COUNT to SUM. Etc.

Changing MAX to MIN would get the smallest.



@mathetes Assuming the area to count is column A to M. Instead of having to define each row (A4: M4), is it possible to do the same count by area (A4:M6) and the outcome is 12?

@Chan_Tze_Leong I have close to 40 excel files with varying areas. So, to do each row range , is very tedious and time consuming. Imagine, for 1 file, I have to select 10 times for 10 rows. Alternatively, selecting the area is only 1 time activity.  



I'm sure something is possible there, but nothing is coming immediately to mind. It would have been helpful had you spelled out the full need at the start, by the way.


Anyway, I'll give it some more thought and try to get back to you in a day or two. In the meantime, maybe somebody else will jump in and help us both.


- select you area

- in Name Box (top left from the grid) type Range and press Enter

- enter the formula in suitable empty cell



thanks,@Sergei Baklan 



Thank you very much @Sergei Baklan 

@Chan_Tze_Leong , glad to help