Search for value in multiple columns

cyoungtx

New Member
Joined
Aug 9, 2011
Messages
12
Excel level - novice

I am using 2 sheets. I am using 2 columns on sheet 1. Column A contains ascending numerical values. Column B needs a formula.

I need to search for the values in column A sheet 1 on multiple columns on Sheet 2. The value will only appear once on each sheet. The formula should return a different result depending on what column it appears in on sheet 2, eg. Column A -"Red", Column B - "Blue", Column C - "Green". This value should return to sheet 1, column B.

Your help is greatly apprecieated!
 
Can you explain how the max is used in the formulas?
Thanks
This expression will return the column number of the referenced range for the column that contains the lookup value and the logical value FALSE for the columns that do not contain the lookup value.

IF(Sheet2!A$2:H$699=A17,COLUMN(Sheet2!A$2:H$5))

This expression returns an array of values but we need to narrow this array down to a single value that is then passed on to the INDEX function. One way to do that is to use the MAX function.

Let's assume this is the table data:

Book1
ABCD
1Color1Color2Color3Color4
255849816
383615712
437916751
570982858
Sheet2

If the lookup value was 67 then:

IF(Sheet2!A$2:D$5=A17,COLUMN(Sheet2!A$2:D$5))

Returns this array:

{FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,3,
FALSE;FALSE,FALSE,FALSE,FALSE}

In this case the lookup value is found in column C (column number 3) so we need to extract that 3 from the array and pass it to the INDEX function. So, we use the MAX function:

MAX(
{FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,3,
FALSE;FALSE,FALSE,FALSE,FALSE})

=3
 
Upvote 0

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,224,607
Messages
6,179,871
Members
452,949
Latest member
Dupuhini

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