I have this Excel file.
The layout is like this:
[Sheet1]
No | Alphabet | Fruit
1 | ABC |
2 | DEF |
3 | GHI |
[Sheet2]
Alphabet | Fruit
ABC | apple
ABC | pear
DEF | vegetable
I'd like to fill in the 'Fruit' column(s) in Sheet1.
What I currently have is this (which I put in C2 and drag down):
=INDEX(list!$A:$B,MATCH($B2,list!$A:$A,0),2)
Unfortunately, this only gives me the first match for each alphabet, like this:
[Sheet1]
No | Alphabet | Fruit
1 | ABC | apple
2 | DEF | vegetable
3 | GHI | #N/A
What I want to do is (in Sheet1) to return all matches under Fruit and replace 'vegetable' and '#N/A' to 'NIL', like this:
[Sheet1]
No | Alphabet | Fruit
1 | ABC | apple | pear
2 | DEF | NIL
3 | GHI | NIL
The following array formula will do somewhat what you want:
=IFERROR(INDEX(Sheet2!$B$2:$B$4,MATCH(1,(Sheet2!$B$2:$B$4<>"Vegetable")*(Sheet2!$A$2:$A$4=$A1)*(COUNTIFS($A1:A1,Sheet2!$B$2:$B$4)=0),0)),"")
It will return a null string instead of NIL
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of enter when Exiting edit mode. If done correctly then Excel will put {} around the formula.
The reason I went with "" instead of "NIL" is that this formula is designed to be drug/copied across and down. It would fill every cell with NIL where the formula is not a fruit.
Related
So I have a case where I need to return all results in a column where 2 criteria are met into one cell.
My table looks something like this
+-----------+------+-------+
| Job | Type | Name |
+-----------+------+-------+
| Tree | AA | Bob |
| Apple | FF | John |
| Banana | FF | John |
| Grape | CC | James |
| Mango | FF | Paul |
| Chocolate | AA | Angus |
+-----------+------+-------+
And I currently use a formula like this:
=IFERROR(INDEX(Table1[Job],MATCH(1,(Table1[Name]=B12) * (Table1[Type]="FF"),0)),"")
Where B12 is an lookup name. However if I was to write John, I'd only get Apple. What I want is "Apple, Banana".
How would I go around doing that?
Use TEXTJOIN as an array formula:
=TEXTJOIN(", ",TRUE,IF((Table1[Name]=B12) * (Table1[Type]="FF"),Table1[Job],""))
Being an array formula it must be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.
TEXTJOIN was introduced with Office 365 Excel.
I'm not sure what to search for this.
Basically, say I have a sheet that looks like this:
A | apple | 1
A | aardvark | 1
A | alternate | 3
B | bear | 2
B | banana | 4
C | candy | 3
C | carnivore | 2
and I want to copy values into another sheet so that it looks like this:
A | apple | 1 | aardvark | 1 | alternate | 3
B | bear | 2 | banana | 4 | |
C | candy | 3 | carnivore | 2 | |
I know there's the lookup function, but I'm not sure how to make it select the first, second, third etc. instance of what's being referenced.
Thanks in advance for any help.
For the screenshot below, use the following formulas:
E2: =IFERROR(INDEX($A$1:$A$8,MATCH(E1,$A$1:$A$8,0)+COUNTIF($A$1:$A$8,E1)),"")
F2:
=IF(INT(COLUMNS($F$1:F$1)/2)<COUNTIF($A$2:$A$8,$E2),INDEX($B$2:$B$8,MATCH($E2,$A$2:$A$8,0)+INT(COLUMNS($F$1:F$1)/2)),"")
G2:
=IF(INT(COLUMNS($G$1:G$1)/2)<COUNTIF($A$2:$A$8,$E2),INDEX($C$2:$C$8,MATCH($E2,$A$2:$A$8,0)+INT(COLUMNS($G$1:G$1)/2)),"")
Select F2 and G2, and fill to the right as far as you need, then fill the entire table down as far as you need.
Using INDEX & MATCH, I'm trying to copy some data across from one worksheet to another (both of which are in the same workbook). I want to grab the description of an item via its ID and it's subset lettering.
EXAMPLE:
Sheet 1 (Destination)
Formula goes here
↓
+------+---+---------------
| A | B | C
---+------+---+---------------
1 | R976 | A | Lazy Brown Dog
2 | R976 | F | Grey Bird
3 | R976 | D | Fox
Sheet 2 (Source)
| A | B | C | D
---+------+--------+---+---------------
1 | ID | Subset | | Description
---+------+--------+---+---------------
2 | R976 | A | | Lazy Brown Dog
3 | R976 | D | | Fox
4 | R976 | F | | Grey Bird
I want the formula in column C of Sheet 1 to grab the description from column D of Sheet 2, based off the ID in column A and the unique letter in column B.
Current:
=INDEX(A1:A4,MATCH(A1,Sheet2!A2:C4, 0))
What I'm trying to do:
=INDEX(A1:A4,MATCH(A1&B1,Sheet2!A2:C4, 0))
However, I'm getting an #NA even after using CTRL+SHIFT+ENTER.
I believe you want Sheet1!C2 to have a formula of:
{=INDEX(Sheet2!$D$1:$D$4,MATCH(Sheet1!$A2&Sheet1!$B2,Sheet2!$A$1:$A$4&Sheet2!$B$1:$B$4,0))}
Then copy that down to cells C3 and C4.
Ok so I am trying to take a common tutorial array formula a step further but cannot figure out how.
Essentially I have a set of sheets with values like below:
| Sheet 1 || Sheet 2 |
| Products(1) | Product Group || Products(2) | Data |
| | || | |
| 100 | 1 || 100 | abc |
| 200 | 2 || 200 | def |
| 300 | 3 || 200 | ghi |
| 400 | 3 || 500 | jkl |
| 500 | 2 || 400 | mno |
Sheet 1 lists all parameters that classify each product and uses those to assign each product to a group. Essentially Products is a unique index key.
Sheet 2 is a tracking list of every time that a product is run, how it did. Therefore product numbers may show up multiple times or not at all.
I have a third sheet in which a product number is entered, from that its group number is calculated, and sheet 1 is searched for all products with that group number and the list is returned using an array formula (using this tutorial http://thinketg.com/how-to-return-multiple-match-values-in-excel-using-index-match-or-vlookup/ which shows up all over on line by different people). We will call this "Column K" on Sheet 3.
What I want to do now is take it a step further and return "Data" from Sheet 2 for all matches between "Sheet 2"!"Products(2)" and "Sheet 3"!"Column K". If "Column K" was fixed I could use the same formula again and put an OR statement into the IF expression, but because K is dynamically populated I am not sure how to find them all.
For clarification, The end result that I would ideally show is like this:
| Sheet 3 |
| Product Num | Column K | Column L | Column M |
| (user enters) | (automatic) | (automatic) | (automatic) |
| 500 | 200 | 200 | def |
| | 500 | 200 | ghi |
| Product Group | | 500 | jkl |
| (automatic) | | | |
| 2 | | | |
If you compare a column vector with an row vector in an array formula then it will compare each value from the column with each value in the row. So the following will work because we transpose the values in Sheet3!K1:K[n] into a row vector before comparing with Sheet2!$A$1:$A$10000.
Sheet1:
Sheet2:
Sheet3:
Formulas in Sheet3:
In A5:
=VLOOKUP($A$2,Sheet1!$A:$B,2,FALSE)
In K2 downwards:
{=IFERROR(INDEX(Sheet1!$A$1:$A$10000,SMALL(IF(Sheet1!$B$1:$B$10000=$A$5,ROW(Sheet1!$B$1:$B$10000)),ROW(1:1))),"")}
In L2 downwards:
{=INDEX(Sheet2!$A$1:$A$10000,SMALL(IF(Sheet2!$A$1:$A$10000=TRANSPOSE($K$1:INDEX($K:$K,MAX(IF($K$1:$K$10000<>"",ROW($K$1:$K$10000))))),ROW(Sheet2!$A$1:$A$10000)),ROW(1:1)))}
In M2 downwards:
{=INDEX(Sheet2!$B$1:$B$10000,SMALL(IF(Sheet2!$A$1:$A$10000=TRANSPOSE($K$1:INDEX($K:$K,MAX(IF($K$1:$K$10000<>"",ROW($K$1:$K$10000))))),ROW(Sheet2!$A$1:$A$10000)),ROW(1:1)))}
Formulas in K2,L2,M2 are array formulas. Input them without the curly brackets and then press [Ctrl]+[Shift]+[Enter].
The reference to K[n] in Sheet3!K1:K[n] is computed with
INDEX($K:$K,MAX(IF($K$1:$K$10000<>"",ROW($K$1:$K$10000))))
therein the
MAX(IF($K$1:$K$10000<>"",ROW($K$1:$K$10000)))
gets the largest row number in column K where the content not equals "".
If the product numbers are ever numeric, then it is easier and it will be possible to have the results sorted also.
Sheet1 and sheet2 see above.
Sheet3:
Formulas in Sheet3:
In A5: see above
In K2 downwards:
{=IFERROR(SMALL(IF(Sheet1!$B$2:$B$10000=$A$5,Sheet1!$A$2:$A$10000),ROW(1:1)),"")}
In L2 downwards:
{=SMALL(IF(Sheet2!$A$2:$A$10000=TRANSPOSE($K$2:INDEX($K:$K,MATCH(MAX($K:$K),$K:$K))),Sheet2!$A$2:$A$10000),ROW(1:1))}
In M2 downwards:
{=INDEX(Sheet2!$B$1:$B$10000,SMALL(IF(Sheet2!$A$1:$A$10000=$L2,ROW(Sheet2!$A$1:$A$10000)),COUNTIF($L$2:$L2,L2)))}
--------------------------------------------------
| X | A | B | C | D |
--------------------------------------------------
| 1 | Fruit | List | Date | Condition |
--------------------------------------------------
| 2 | Banana | Banana | 02/05/2010 | Good |
--------------------------------------------------
| 3 | Tomato | Banana | 02/05/2014 | Excellent |
--------------------------------------------------
| 4 | Orange | Banana | 02/05/2011 | Bad |
--------------------------------------------------
I would like to compare one-by-one the items in column A with column B, then return what's in column D for the most recent date in column C for that item.
E.g.: For "Banana" (A2) - Result = Excellent
I tried some INDEX with MATCH, but I can't get the correspondent MAX value.
Thanks
This is an array formula. Enter it in E2 by holding down ctrl-shift while hitting enter. Excel will put curly braces {...} around the formula:
=IF(COUNTIF(List,A2),INDEX(Condition,MATCH(MAX((A2=List)*Date),(A2=List)*Date,0)),"")
List, Condition, and Date are named ranges corresponding to the appropriate columns. eg: B2:b7, C2:c7, D2:d7.
This screenshot is based on your original post, as edited by me before you edited it your way: