简体   繁体   中英

Count the number of columns with nonblank cells excel formula

I'm trying to count the number of columns that contain some text. So for example:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
xxx

xxxxxx xxx

xxxxxxxxxxxxxxxxxxxxxxxxx

Something like that should return "13". Doesn't matter how many cells contain text in the column, all I care about is how many columns contain text. Any suggestions?

While this isn't sophisticated coding or anything, this has worked well for me in the past.

At the top of each column (above the header, somewhere not in the way and that you won't need to use) add a CountA() formula that tells you how many cells in that column are not empty.

Put that inside an IF statement. =If(CountA("YourColumnRange") > 0, 1, 0)

Then, where ever you need it, sum up the results of each of the formulas for those columns and that will give you the total number of columns you are looking for.

If you don't want to display the "1" or "0" at the top of each column, simply change the text color in those cells to match your background (default being to change the text color to white).

Let me know if any of that needs clarification.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM