Extract the last value in the row with a condition

sofas

Active Member
Joined
Sep 11, 2022
Messages
472
Office Version
  1. 2019
Platform
  1. Windows
Welcome. Please help in extracting the last test that was completed, subject to the subject number, so that when
writing the subject number in column (H), the name of the last test with a value in column (i)
is obtained. It does not matter, whether by formula or vba code.


Capture.PNG
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Try:

Book2 (version 1).xlsb
ABCDEFGHI
1Materialstest1test2test3test4test5MaterialsThe last test
21461test3
32592test5
4352693test3
54111024test5
655#N/A
761046test2
Sheet1
Cell Formulas
RangeFormula
I2:I7I2=LOOKUP(2,1/INDEX($B$2:$F$7,MATCH(H2,$A$2:$A$7,0),0),$B$1:$F$1)
 
Upvote 1
Try:

Book2 (version 1).xlsb
ABCDEFGHI
1Materialstest1test2test3test4test5MaterialsThe last test
21461test3
32592test5
4352693test3
54111024test5
655#N/A
761046test2
Sheet1
Cell Formulas
RangeFormula
I2:I7I2=LOOKUP(2,1/INDEX($B$2:$F$7,MATCH(H2,$A$2:$A$7,0),0),$B$1:$F$1)
Very cool, this is what needs to be done. Is there a possibility to add the phrase Not Found inside the formula when no value is found instead of #N/A?
 
Upvote 0
Sure,

Excel Formula:
=IFERROR(LOOKUP(2,1/INDEX($B$2:$F$7,MATCH(H2,$A$2:$A$7,0),0),$B$1:$F$1),"Not found")

Glad I could help! :cool:
 
Upvote 1
Sure,

Excel Formula:
=IFERROR(LOOKUP(2,1/INDEX($B$2:$F$7,MATCH(H2,$A$2:$A$7,0),0),$B$1:$F$1),"Not found")

Glad I could help! :cool:
Very good thank you very much I appreciate your help
 
Upvote 0
Sure,

Excel Formula:
=IFERROR(LOOKUP(2,1/INDEX($B$2:$F$7,MATCH(H2,$A$2:$A$7,0),0),$B$1:$F$1),"Not found")

Glad I could help! :cool:
Thank you again. I have greatly benefited from your suggestion. One last request, please. What can I change if I want to get the first value that is opposite to what is in the previous suggestion?
 
Upvote 0
One way:

Book1
ABCDEFGHIJ
1Materialstest1test2test3test4test5MaterialsThe last testFirst test
21461test3test1
32592test5test2
4352693test3test1
54111024test5test3
655Not foundNot found
761046test2test2
Sheet2
Cell Formulas
RangeFormula
I2:I7I2=IFERROR(LOOKUP(2,1/INDEX($B$2:$F$7,MATCH(H2,$A$2:$A$7,0),0),$B$1:$F$1),"Not found")
J2:J7J2=IFERROR(INDEX($1:$1,AGGREGATE(15,6,COLUMN($B$1:$F$1)/(INDEX($B$2:$F$7,MATCH(H2,$A$2:$A$7,0),0)<>""),1)),"Not found")


I think there's an easier way, but the new functions (Excel 2021 and newer) have spoiled me and I've forgotten how to do things. But this should work for you. Incidentally, if you change the 15 in that formula to a 14, it works the same as the prior formula to get the last test.
 
Upvote 1
Solution

Forum statistics

Threads
1,215,239
Messages
6,123,816
Members
449,127
Latest member
Cyko

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