Counting columns in a dynamic range

seleseped

Board Regular
Joined
Feb 1, 2005
Messages
59
Hello,
I have an attendance sheet where students' names are in column A, attendance percentage (calculated using data from columns C and beyond) in column B, and the dates of classes are in columns C and beyond. A new column is filled with each class held where 'true' indicates that the student was present in class and 'false' if not. To calculate the attendance percentage, I need to count the number of 'true' values in columns C and beyond. I would like help with an Excel formula (not VBA) which counts the number of filled columns to determine the denominator of the percentage. I know that something like:

=COUNTIF(3:3,"TRUE")

will not work since cells A3 and B3 do not include attendance data and give a circular reasoning error since my calculated result is in B3. I need a formula which starts at C3 then identifies the last filled column in row 3. I could use a far-right cell reference such as:
=COUNTIF(C3:ZZ3,"TRUE") but that is not elegant programming technique and I need to learn!

Thanks to you in advance for your time and expertise!
 

Some videos you may like

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

seleseped

Board Regular
Joined
Feb 1, 2005
Messages
59
Does this help?

c3:index(c3:zz3,match(rept("z",255),c3:zz3))

I don't think so. I gave the ZZ3 as an example. In reality, the number of columns changes. For example, one week the columns may go from C to G, then the next week (after 5 more classes) the columns will go from C to L. I need a formula which will count the number of columns as they expand to the right over time.

Thank you.
 

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,201
I don't think so. I gave the ZZ3 as an example. In reality, the number of columns changes. For example, one week the columns may go from C to G, then the next week (after 5 more classes) the columns will go from C to L. I need a formula which will count the number of columns as they expand to the right over time.

Thank you.

c3:index(c3:zz3,match(rept("z",255),c3:xfd3))

match(rept("z",255),c3:xfd3)

provided that all those true's are text, not a logical value, as you claimed.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,516
Messages
5,602,110
Members
414,504
Latest member
Ganga Praveen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top