AutoFill formula in a column based on data in a row

armsafna

New Member
Joined
Mar 12, 2023
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Say I have an attendance list for a class:

StudentClass 1Class 2Class 3Total
AlphaXXXCOUNTIF(B2:C2,"X") = 3
BravoX1
CharlieXXX3
DeltaXX2
EchoXXX3
FoxtrotXXX3
GolfXXX3

The Class1:Class3 fields are data-validated to have Xs or Blanks depending on whether a student is present or not.
The Total column counts Xs in the corresponding row to get an attendance total for the student.

I have another table tracking Class data, as opposed to student date:

ClassAttendance total
1=COUNTIF(Table1[B2:B8],"X") = 8
2
3

I use a COUNTIF function in the 'Attendance Total' column to add Xs in the corresponding class column in the other table. But... the formula doesn't AutoFill properly!
Can I not AutoFill a formula in a column based on a pattern that varies by row?
Any workarounds?

Trying to complete report card season in 5 minutes.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
oops the COUTNIF in 'Attendance Total' should equal 7 guess I can't math without excel L.
 
Upvote 0
How about
Fluff.xlsm
ABCDEFGH
1StudentClass 1Class 2Class 3TotalClassAttendance total
2AlphaXXX317
3BravoX125
4CharlieXXX336
5DeltaXX2
6EchoXXX3
7FoxtrotXXX3
8GolfXXX3
9
Data
Cell Formulas
RangeFormula
H2:H4H2=COUNTIF(INDEX($B$2:$D$8,,MATCH($G$1&" "&G2,$B$1:$D$1,0)),"X")
E2:E8E2=COUNTIF(B2:D2,"X")
 
Upvote 1
Solution
How about
Fluff.xlsm
ABCDEFGH
1StudentClass 1Class 2Class 3TotalClassAttendance total
2AlphaXXX317
3BravoX125
4CharlieXXX336
5DeltaXX2
6EchoXXX3
7FoxtrotXXX3
8GolfXXX3
9
Data
Cell Formulas
RangeFormula
H2:H4H2=COUNTIF(INDEX($B$2:$D$8,,MATCH($G$1&" "&G2,$B$1:$D$1,0)),"X")
E2:E8E2=COUNTIF(B2:D2,"X")
Oh that works perfectly. So it basically says to count the Xs in the attendance table starting with the first row (because row # isn't specified) and in the column that matches a specific expressed during lookup as a concatenation of the word "Class" and the class number - does that sound right?

Can INDEX and MATCH be nested as such to avoid the column to row formula fill dilemma in general?
 
Upvote 0
Not quite sure what you mean by this.
If I have a series of columns in Table1 with Xs in them which I want to count and output in a single column in Table2, with each cell in that column in Table2 corresponding to all the Xs in a column in Table1. So for example =COUNTIF(Table1[Column1],"X") counts the Xs in Column1 of Table1 and outputs it in Column2 of Table2 (because Column1 in Table2 is just the name of the lesson). If I drag the formula from the first cell in Column1 of Table2 downward through the column to autocomplete, what I want it to do is understand that I want =COUNTIF(Table1[Column2],"X") and then =COUNTIF(Table1[Column3],"X"), but it doesn't recognize the pattern.

What you have done with =COUNTIF(INDEX(Table1[[Column1]:[Column3],,MATCH([@Column1],Table1[#Headers],[Column1]:[Column3],0)),"X") is basically made it so that everything is absolute reference except for the Lookup Value in MATCH (which tracks down Column1) so now if I try and complete the Formula in a column, it is doing what it seems to want to do which is change the formula to move one cell down in Column1 in Table2 per cell I move down in Column2 in Table2.

This might make no sense but overall the INDEX and MATCH combo seems to erase a lot of the ambiguity tysm.
 
Upvote 0
Still not quite sure what you mean. Does the formula you posted do what you want?
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,316
Members
452,634
Latest member
cpostell

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
Back
Top