Return certain words in certain cells in order based on range values

bakarken

Board Regular
Joined
Sep 23, 2016
Messages
50
Office Version
  1. 2019
Platform
  1. Windows
Hi guys


This is quite a confusing question, so I hope I can word it so that you understand.


I am using Excel 2010, and I am looking for an Excel formula (not VBA) to do the following.


On row 1, I have words in columns A - E in a certain order which for this example we can say are


A1: "Excel1"
B1: "Excel2"
C1: "Excel3"
D1: "Excel4"
E1: "Excel 5"


On 'Sheet2', there is a list of data where in column A there is a variety of entries which the user types. Any entry in the A section of 'Sheet2' must be one of the five options on the top row of 'Sheet1' (Excel1, Excel2 etc.)


I am looking for a formula to enter into 'Sheet1' row TWO (A2:E2) that returns the left-most option from A1:E1 IF it appears in the range in 'Sheet2'


So if the user enters 'Excel5' into the column for example, cell A2 will say 'Excel5' as this is the left most option.


If the user enters 'Excel2' and 'Excel3' into the column, this would return 'Excel2' into A2 and 'Excel3' into B2


If the user had all five options somewhere in Sheet2!A:A, A2 to E2 would show exactly what A1 to E1 would show but this may not always happen.


I think I need to use something like =if(countif('Sheet2'!A:A,"Excel1)>0,"Excel1",if(countif('Sheet2'!A:A,"Excel2")>0,"Excel 2"


etc, but I am struggling Can anyone help?
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Try putting this in Sheet1, A2:

=IFERROR(INDEX(Sheet2!$A$1:$A$100,AGGREGATE(15,3,MATCH($A$1:$E$1,Sheet2!$A$1:$A$100,0),COLUMNS($A2:A2))),"")
confirm with Control+Shift+Enter. Then drag to the right.
 
Upvote 0
Hi Eric

Thanks so much for the reply, but that does not seem to be displaying them in the correct order.

If A1:A100 said Excel3, Excel4, Excel1, they would be shown in this order but what I want is Excel1, Excel3 and Excel4, if that makes sense?

Thank you
 
Upvote 0
OK, give this one a try:

=IFERROR(INDEX($1:$1,SMALL(IF(ISNUMBER(MATCH($A$1:$E$1,Sheet2!$A$1:$A$100,0)),COLUMN($A$1:$E$1)),COLUMNS($A$2:A$2))),"")
confirm with Control+Shift+Enter.
 
Upvote 0
Hi Eric

That appears to have worked very well, thank you!

Whilst trying to translate this example formula into my actual data, I am also struggling to insert the formula as if two different sheets were being searched for data.

So in my first example, 'Sheet2'!A1:A100 was the range of search, but what if I wanted to look through both 'Sheet2'!A1:A100 and 'Sheet3'!A1:A100 and place the categories in order considering both sheets of data, is that possible?
 
Upvote 0
Try this:

=IFERROR(INDEX($1:$1,SMALL(IF(ISNUMBER(MATCH($A$1:$E$1,Sheet2!$A$1:$A$100,0))+ISNUMBER(MATCH($A$1:$E$1,Sheet3!$A$1:$A$100,0)),COLUMN($A$1:$E$1)),COLUMNS($A$2:A$2))),"")

with Control+Shift+Enter
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,583
Members
449,089
Latest member
Motoracer88

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