Lookup and return over multiple columns

thechump

New Member
Joined
Nov 2, 2017
Messages
3
Hi, I am a teacher and need to record the results from collaborative paired projects for my class. The idea being that I am able to see the effect of different partnerships on test results. I also need to set incremental targets based on personal attainment. I am struggling to write the formulas required to look up a value over two columns and return a value from on of two columns. For example -

Week 1 testing

[TABLE="width: 500"]
<tbody>[TR]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[TD="align: center"]E[/TD]
[TD="align: center"]F[/TD]
[/TR]
[TR]
[TD]Child 1[/TD]
[TD]Child 2[/TD]
[TD]Target child 1[/TD]
[TD]Target child 2[/TD]
[TD]Results child 1[/TD]
[TD]Result child 2[/TD]
[/TR]
[TR]
[TD]Joe[/TD]
[TD]Frank[/TD]
[TD][/TD]
[TD][/TD]
[TD]12[/TD]
[TD]14[/TD]
[/TR]
[TR]
[TD]Bill[/TD]
[TD]Peter[/TD]
[TD][/TD]
[TD][/TD]
[TD]10[/TD]
[TD]13[/TD]
[/TR]
</tbody>[/TABLE]

Week 2 testing - I want to be able to enter a formula in columns C and D that lookup the name in column A/B and return their results from E/F. The partners have swapped and I can add a calculation to add an increment to the target if I can get the lookup working.

[TABLE="width: 500"]
<tbody>[TR]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[TD="align: center"]E[/TD]
[TD="align: center"]F[/TD]
[/TR]
[TR]
[TD]Child 1[/TD]
[TD]Child 2[/TD]
[TD]Target child 1[/TD]
[TD]Target child 2[/TD]
[TD]Results child 1[/TD]
[TD]Result child 2[/TD]
[/TR]
[TR]
[TD]Joe[/TD]
[TD]Bill[/TD]
[TD]12[/TD]
[TD]10[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Frank[/TD]
[TD]Peter[/TD]
[TD]14[/TD]
[TD]13[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


I'm struggling to understand if this is possible and also how I could return the last known results when I have multiple weeks of results.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hello.... try this out in cell C2 which is where your result 12 for Joe for week 2 is at

=IFERROR(INDEX($E$2:$E$3,MATCH(A10,$A$2:$A$3,0)),INDEX($F$2:$F$3,MATCH(A10,$B$2:$B$3,0)))
 
Upvote 0
As above, I'm not 100% sure I got the requirements right and I'm sure there's an easier way to do this but the issue is with finding the right column for a child.


Book1
ABCDEF
1Child 1Child 2Target Child 1Target Child 2Results Child 1Results Child 2
2JoeFrank1214
3BillPeter1013
4JoeBill1210139
5FrankPeter14131016
6PeterJoe1613
7BillFrank910
Sheet1
Cell Formulas
RangeFormula
C4{=IF(INDEX($A$1:$B3,MAX(IF($A$2:$B3=A4,ROW($A$2:$B3))),1)=A4,INDEX($E$1:$E3,MAX(IF($A$2:$B3=A4,ROW($A$2:$B3)))),INDEX($F$1:$F3,MAX(IF($A$2:$B3=A4,ROW($A$2:$B3)))))}
D4{=IF(INDEX($A$1:$B3,MAX(IF($A$2:$B3=B4,ROW($A$2:$B3))),1)=B4,INDEX($E$1:$E3,MAX(IF($A$2:$B3=B4,ROW($A$2:$B3)))),INDEX($F$1:$F3,MAX(IF($A$2:$B3=B4,ROW($A$2:$B3)))))}
Press CTRL+SHIFT+ENTER to enter array formulas.


That will retrieve the latest result for a child and put it in the target but it's not very efficient as it runs the same array formula three times.

WBD
 
Upvote 0
Thank you so much....that works fantastically well!

Is there a way of the formula selecting the last score occurrence for each child as the weeks go by. I can see that you have used static references for the range. Is there a way of making that dynamic over the last say 20 records (this should cover 2 weeks worth of testing so if a child is absent one week, it will still pull their last score.)
 
Upvote 0
Similar solution without array formula:


Book1
ABCDEF
1Child 1Child 2Target Child 1Target Child 2Results Child 1Results Child 2
2JoeFrank1214
3BillPeter1013
4JoeBill1210139
5FrankPeter14131016
6PeterJoe1613
7BillFrank910
Sheet1
Cell Formulas
RangeFormula
C4=IF(SUMPRODUCT(MAX(ROW($A$1:$A3)*($A$1:$A3=A4)))>SUMPRODUCT(MAX(ROW($B$1:$B3)*($B$1:$B3=A4))),LOOKUP(2,1/($A$1:$A3=A4),$E$1:$E3),LOOKUP(2,1/($B$1:$B3=A4),$F$1:$F3))


Copy C4 formula across to D4 and then down as far as necessary.

WBD
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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