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!
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
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!
Are those the column headers where the number will appear?

Like this:

Book1
ABC
1RedBlueGreen
2389381
3124426
4341433
5291525
Sheet2

So, if we were searching for number 14 we'd want to return the column header Blue?

Is this correct?
 
Upvote 0
Hi:)

2 sheets
Sheet1 2 columns and 10 rows each
Sheet2 3 columns and 10 rows each

In sheet1 select all the rows in Column B
Go to Home Tab, Conditional Formatting, New Rule, Use formula, and Enter the following:

For Red:
=MAX(IF(Sheet2!$A$1:$C$10=Sheet1!A1,COLUMN(Sheet2!$A$1:$C$1)-COLUMN(Sheet2!$A$1)+1,""))=1

For Blue:
=MAX(IF(Sheet2!$A$1:$C$10=Sheet1!A1,COLUMN(Sheet2!$A$1:$C$1)-COLUMN(Sheet2!$A$1)+1,""))=2

For Green:
=MAX(IF(Sheet2!$A$1:$C$10=Sheet1!A1,COLUMN(Sheet2!$A$1:$C$1)-COLUMN(Sheet2!$A$1)+1,""))=3
Excel Workbook
AB
1232
222
3252
4163
543
6241
7252
8171
972
1043
Sheet1
Excel 2010
#VALUE!
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
 
Upvote 0
T. Valko, your response was accurate. I am trying to return the value of the color name. I can use it as the header for the column on sheet 2.
 
Upvote 0
MrVillareal, I am looking for column B sheet 1 to return the actual color name from the corresponding color column on sheet 2.
 
Upvote 0
T. Valko, your response was accurate. I am trying to return the value of the color name. I can use it as the header for the column on sheet 2.
OK, based on the sample I posted...

On Sheet1 cell A2 = 14

Enter this array formula** in B2:

=INDEX(Sheet2!A1:C1,MAX(IF(Sheet2!A2:C5=A2,COLUMN(Sheet2!A2:C5)))-COLUMN(Sheet2!A2)+1)

** array formulas need to be entered using the key
combination of CTRL,SHIFT,ENTER (not just ENTER).
Hold down both the CTRL key and the SHIFT key
then hit ENTER.
 
Upvote 0
MrVillareal, I am looking for column B sheet 1 to return the actual color name from the corresponding color column on sheet 2.

Ok how about this.
Excel Workbook
AB
123Blue
22Blue
325Blue
416Green
54Green
624Red
725Blue
817Red
97Blue
104Green
Sheet1
Excel 2010
#VALUE!
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
 
Upvote 0
Here is the sheet 2 for your verification.
Excel Workbook
ABC
1RedBlueGreen
217123
3293018
427226
511234
6212028
72471
819813
992522
1061016
1115145
Sheet2
Excel 2010
 
Upvote 0
Thanks for the replies, I'm trying to get this to work properly. Can this work as an IF function, asking IF the number is added to sheet 1 and also appears in the columns of Sheet 2, then return the 'color' value. And if the value is not listed on Sheet 2 then the cell is left blank?
 
Upvote 0
Thanks for the replies, I'm trying to get this to work properly. Can this work as an IF function, asking IF the number is added to sheet 1 and also appears in the columns of Sheet 2, then return the 'color' value. And if the value is not listed on Sheet 2 then the cell is left blank?
Yes, that can be done. The best approach depends on what version of Excel you're using?
 
Upvote 0

Forum statistics

Threads
1,224,604
Messages
6,179,857
Members
452,948
Latest member
UsmanAli786

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