Forum Discussion

Chan_Tze_Leong's avatar
Chan_Tze_Leong
Brass Contributor
Feb 10, 2021

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

  • mathetes's avatar
    mathetes
    Gold Contributor

    Chan_Tze_Leong 

     

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

    =MAX(COUNT(A4:L4),COUNT(A5:L5),COUNT(A6:L6))

     

    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.

     

     

    • Chan_Tze_Leong's avatar
      Chan_Tze_Leong
      Brass Contributor

      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's avatar
        Chan_Tze_Leong
        Brass Contributor

        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.  

Resources