Formula: Search value in range and return another value on same row

vabtroni

New Member
Joined
Aug 1, 2017
Messages
41
Office Version
  1. 365
Platform
  1. Windows
Hello everyone, good evening! đź‘‹ :)

I have a table on wich I organize the tasks assigned to a given fleet of vehicles during the day. For example, vehicle 100 will perform the tasks "S32", "SW3" and "NE32". These are random names, no speacial meaning on any of them.

On the right, on range L2:M3 I have a little "search box" on wich I insert a task name on M2, and I need a formula on M3 that returns the vehicle that is performing that task. For example, if I write "S10" on M2, M3 should display "102", meaning that vehicle 102 is performing task "S10".

Could anyone shed some light on this one?

Best regards,
V

help.jpg
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Excel Formula:
=INDEX($B$1:$B$7,AGGREGATE(15,6,ROW($B$2:$B$7)/($B$2:$E$7=$M$2),1))
 
Upvote 0
Excel Formula:
=INDEX($B$1:$B$7,AGGREGATE(15,6,ROW($B$2:$B$7)/($B$2:$E$7=$M$2),1))
I would say that formula is a bit 'risky' (apart from the range B2:E7 not being wide enough). If any new rows are subsequently added above the data it will return incorrect result.
It could easily be made more robust as follows. I have also increased the width of the scanned range in line with the image in post 1.

23 01 13.xlsm
ABCDEFGHIJKLM
1
2Vehicle #TasksS10
3100S32SW3NE32102
4101NE4NW34
5102DTWNINDS10S11
6103401
7104SW91SE11S900
Lookup Vehicle
Cell Formulas
RangeFormula
M3M3=INDEX(B:B,AGGREGATE(15,6,ROW($B$2:$B$7)/($B$2:$J$7=$M$2),1))
 
Upvote 0
Excel Formula:
=INDEX($B$1:$B$7,MAX(ROW($B$3:$B$7)*--($M$2=$C$3:$J$7)))
Exactly the same problem as post #2 formula if rows are subsequently added at the top.
(BTW, "--" is not required in the formula)
 
Upvote 0
Thank you all for your answers. Will try the formula as soon as possible.

However, I can assure you all one thing: the workspace is heavily protected, so there is no chance that the user can add or delete rows while using the sheet. :cool:

Will feedback later today. Cheers everyone!
 
Upvote 0
the workspace is heavily protected, so there is no chance that the user can add or delete rows while using the sheet.
Still, in my view, good practice to get into the habit of using formulas that are as robust as possible, particularly if they are no more complex than the alternative. :)
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,094
Latest member
teemeren

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