Excel Formula INDEX+AGREGATE+ORDER by another column - excel

I have an excel formula that I need help with, since I'm not that savvy on excel.
The formula is the following:
=IFERROR(INDEX(Liste!$C$2:$N$10000,AGGREGATE(15,6,(ROW(Liste!$A$2:$A$10000)-ROW(Liste!$A$2)+1)/ISNUMBER(SEARCH("BOX"," " & Liste!$B$2:$B$10000 & " ")),ROWS($A$4:$A4)),COLUMN()-1),"")
This formula looks on another sheet (Liste) for lines containing the word BOX on column B and show them on "ROWS($D$4:$D4)" (in this case) starting from Column "C".
I'm not even sure if that formula orders the results on column "B" since they're all the same with the word "BOX".
It works prefectly, the only think I can't achieve (and I've tried diferent combinations) is to change that code to make it show the results in order according to column "C" (not column B).
Sample Data:
Sheet "Liste"
|-----------|----------|-----------|
| B | C | D |
|-----------|----------|-----------|
| NOTBOX | 5 | SAMPLE |
| BOX | 3 | SAMPLE |
| BOX | 1 | SAMPLE |
| BOX | 2 | SAMPLE |
| NOTBOX | 4 | SAMPLE |
|-----------|----------|-----------|
Current Result:
|-----------|----------|
| A | B |
|-----------|----------|
| 3 | SAMPLE |
| 1 | SAMPLE |
| 2 | SAMPLE |
|-----------|----------|
Desired Result:
|-----------|----------|
| A | B |
|-----------|----------|
| 1 | SAMPLE |
| 2 | SAMPLE |
| 3 | SAMPLE |
|-----------|----------|
Can someone give me a hand?
One thing I forgot to state is that I need to drag this formula around (rows and columns) so it's important that I can drag it on a large zone (if lines are added in the future) and that it ignores the errors (blank).
Thank you in advance

Here is an example on how you could do this:
Formula in F2:
=SMALL(IF($A$2:$A$6=$E$2,$B$2:$B$6,""),ROW(A1))
Or in French
=PETITE.VALEUR(SI($A$2:$A$6=$E$2;$B$2:$B$6;"");LIGNE(A1))
Formula in G2:
=INDEX($C$2:$C$6,MATCH(F2,$B$2:$B$6,0))
Or in French
=INDEX($C$2:$C$6;EQUIV(F2;$B$2:$B$6;0))
Note: The first formula is an array formula and need to be confirmed through CtrlShiftEnter.
Drag them both down and include an IFERROR if you drag these formula's down and you don't want to see errors once there are no more hits.

Related

Combining rows of a table using similar cells of one of its columns in Excel

I have a table (1) in Excel, with two columns, in which at the first column (A) there are some numbers and at the second column (B) there are some letters. I want to have a method to make another table (2) from (1) to put different letters at the first column then to put in each row the numbers that were corresponded to letters in table (1).
For example, let the table (1) is:
| A | B |
|---|---|
| 1 | a |
| 1 | b |
| 2 | a |
| 2 | c |
| 3 | b |
| 4 | b |
What is a method in Excel which make the following combination table:
| a | 1 | 2 | |
| b | 1 | 3 | 4 |
| c | 2 | | |
in which letters are in first column and in each row there are the numbers that were in relationship with the row's letter in table (1)?
As per below screenshot use below formula to C1 cell.
=UNIQUE(B1:B6)
And following formula to D2 cell then drag down
=TRANSPOSE(UNIQUE(FILTER($A$1:$A$6,$B$1:$B$6=C1)))

Match column value with substring from reference table in Excel

I have a reference table on sheet1
| A | B |
|---------------|----------|
| dog | 10 |
|---------------|----------|
| cat | 20 |
|---------------|----------|
I then have a list with values on sheet 2
| D | E |
|-------------------|----------|
| wild dog 2 | |
|-------------------|----------|
| strange cat Willy | |
|-------------------|----------|
I would like E to contain the value of B from the reference table, using the first substring match
I tried with VLOOKUP and INDEX ( MATCH ..) but this is not getting me anywhere. Help or pointers appreciated.
With your current sample data following formula will work. But don't know how is your actual data.
=INDEX($B$1:$B$10,MATCH(TRIM(MID(SUBSTITUTE(D1," ", REPT(" ",100)),100,100)),$A$1:$A$10,0))
I ended up using the formula from Harun24HR and simplifying it.
=(INDEX($B$1:$B$10;MATCH(1;COUNTIF(D1;"*" & $B$1:$B$10 & "*");0));

Conditionally copy information from an Excel table to another sheet

I have a table in an Excel sheet that is made up of 4 columns. Columns 2-4 have formulas in them. The 4th column has temperatures in it, and once it hits a certain temperature range I would like columns 1-4 (preferably) to copy over into another sheet.
How can I do that? I have tried to do a vlookup, but I don’t think it works because of the formulas in columns 3 and 4.
Do you have an example of data?
All i can think off is an lookup inside an 'If' statement
Eg.
| Column1 | Formula | Formula | Temperature |
| Text | text | text | 20 |
| Text | text | text | 25 |
| Text | text | text | 30 |
so maybe a helper column to the right
| Column1 | Formula | Formula | Temperature |Helper column |
| Text | text | text | 20 | 0 |
| Text | text | text | 25 | 1 |
| Text | text | text | 30 | 1 |
with the formula
=if(Temperature>"value","1","0")
=if(Temperature>"24","1","0")
Then use an if in your new column on different sheet saying
=if(Helper column = 1, column1, "")
In your new table
Hopefully that makes a bit of sense although it is tricky without seeing example data.
if you are ok with VBA this could probably be way easier to do!

excel return the value of a cell based on two other values

What I'm trying to do is a little complex but I think it's doable in Excel.
I have two worksheets in a workbook on sheet one I have this...
| Code1 | Code2 | Code3 | Code4 |
| BA1 | xxxxx | xxxxx | |
| BA2 | xxxxx | xxxxx | |
| BA3 | xxxxx | xxxxx | |
And on the second sheet...
| CodeA | CodeB | CodeC | CodeD |
| BA1 | 1 | date | text |
| BA3 | 1 | date | text |
| BA1 | 2 | date | text |
| BA2 | 1 | date | text |
| BA1 | 3 | date | text |
| BA3 | 2 | date | text |
| BA2 | 2 | date | text |
What I want to do is lookup Code1 on sheet one and find it in the second sheet in CodeA then find the highest CodeB for CodeA and then concatenate CodeC and CodeD and place them on Sheet one in Code4.
I hope that makes sense, Thanks for any advice.
I think I understand. Does this look correct?
Sorry for the swedish formulas but it's an array formula that you add with CTRL+SHIFT+ENTER.
The formula in english is:
{=MAX(IF(Data=A2,CodeB;-1))}
And the named range Data is Column H and I, and CodeB is Column I.
If it does not find the value it returns -1
Sorry noticed now that I only did half of the job.
Make another named range called Table that spans column I to K (Code B -> Code D).
And in column code3 add this formula:
=Vlookup(B2,Table,2,false)
And in code4:
=Vlookup(B2,Table,3,false)
And you should get:
This should find the results you are looking for.
This is an array formula so you will need to press CTRL+SHIFT+ENTER once you have entered it into the formula bar, this will have to done for every formula you add to the column.
As it is an array formula I have only written it to reference rows 1 to 18, you will need to update all references to include you last row.
Columns titled CODE1(to 4) are on the first sheet (Sheet 1)
Columns titled CODEA(to D) are on the Second sheet (Sheet 2)
=CONCATENATE(VLOOKUP(CONCATENATE(A2,MAX(IF(Sheet2!A:A=A2,Sheet2!B:B,-1))), CHOOSE({1,2},Sheet2!A1:A18 & Sheet2!B1:B18, Sheet2!C1:C18 ),2,0)," ",VLOOKUP(CONCATENATE(A2,MAX(IF(Sheet2!A:A=A2,Sheet2!B:B,-1))), CHOOSE({1,2},Sheet2!A1:A18 & Sheet2!B1:B18, Sheet2!D1:D18 ),2,0))
If you do not require a space between the dates, just remove " ", from the middle of the formula.

Excel Formula Optimisation

I am no excel expert and after some research have come up with this formula to look at two sets of the same data from different times. It then displays new entries that are in the latest list of data but not in the old list.
This is my formula:
{=IF(ROWS(L$4:L8)<=(SUMPRODUCT(--ISNA(MATCH($E$1:$E$2500,List1!$E$1:$E$2500,0)))),
INDEX(E$1:E$2500,
SMALL(IF(ISNA(MATCH($E$1:$E$2500&$F$1:$F$2500,List1!$E$1:$E$2500&List1!$F$1:$F$2500,0)),
ROW($F$1:$F$2500)-ROW($F$1)+1),ROWS(L$4:L8))),"")}
Are there any optimisation techniques I could employ to speed up the calculation?
As requested
Some example data(link to a spreadsheet):
https://docs.google.com/file/d/0B186C84TADzrMlpmelJoRHN2TVU/edit?usp=sharing
On this scaled down version its more efficent but on my actual sheet with a lot more data it is slowed.
Well, I was playing around a bit and I think that this works the same, and without the first IF statement:
=IFERROR(INDEX(A$1:A$2500,SMALL(IF(ISNA(MATCH($A$1:$A$2500&$B$1:$B$2500,List1!$A$1:$A$2500&List1!$B$1:$B$2500,0)),ROW($B$1:$B$2500)-ROW($B$1)+1),ROWS(F$2:F2))),"")
That part in your sample data:
ROWS(F$2:F2)<=(SUMPRODUCT(--ISNA(MATCH($A$1:$A$2500,List1!$A$1:$A$2500,0))))
As I understood it, it only sees to it that the row number in which the formula is entered is lower than the number of 'new' items, but it doesn't serve any purpose because when you drag the formula more than required, you still get errors instead of the expected blank. So I thought it could be removed altogether (after trying to substitute it with COUNTA() instead) and use an IFERROR() on the part directly fetching the details.
EDIT: Scratched that out. See barry houdini's comment for the importance of those parts.
Next, you had this:
ROW($B$1:$B$2500)-ROW($B$1)+1
-ROW($B$1)+1 always returns 0, so I didn't find any use to it and removed it altogether.
It's still quite long and takes some time I guess, but I believe it should be faster than previously by a notch :)
A relatively fast solution is to add a multi-cell array formula in a column alongside List 2
{=MATCH($A$1:$A$16,List1!$A$1:$A$11,0)}
and filter the resultant output for #N/A.
(Or see Compare.Lists vs VLOOKUP for my commercial solution)
Array formula is slow. When you have thousands of array formula, it will make the speed very slow. Thus the key will be to avoid any array formula.
The following will be my way to achieve it, using only simple formula. It should be fast enough if you only have 2500 rows.
Column F and H are "Keys", created by concatenating your 2 columns (E and F in your original formula)
Assuming the first line of data is on row 3.
Data:
| A | B | | D | E | F | | H |
| index | final value | | ID | exist in Old? | Key (New) | | Key (Old) |
--------------------------------------------------------------------------------
| 1 | XXX-33 | | 0 | 3 | OOD-06 | | OOC-01 |
| 2 | ZZZ-66 | | 0 | 1 | OOC-01 | | OOC-02 |
| 3 | ZZZ-77 | | 1 | N/A | XXX-33 | | OOD-06 |
| 4 | | | 1 | 4 | OOE-01 | | OOE-01 |
| 5 | | | 1 | 2 | OOC-02 | | OOF-03 |
| 6 | | | 2 | N/A | ZZZ-66 | | |
| 7 | | | 3 | N/A | ZZZ-77 | | |
Column E "exist in Old?": test if the new key (Column F) exists in the old list (Column H)
=MATCH(F3, $H$3:$H$2500, 0)
Column D "ID": to increment by one whenever a new item is found
=IF(ISNA(E3), 1, 0)+IF(ISNUMBER(D2), D2, 0)
the 2nd part of ISNUMBER is just for the first row, where just using D2 can cause an error
Column A "index": just a plain series starting from 1 (until the length of new list Column F)
Column B "final value": to find the new key by matching column A to Column D.
=IF(A3>MAX($D$3:$D$2500), "", INDEX($F$3:$F$2500, MATCH(A3, $D$3:$D$2500, 0))
This column B will be the list you want.
If it is still too slow, there exists some dirty tricks to speed up the calculation, e.g. by utilizing a sorted list with MATCH( , , 1) instead of MATCH( , , 0).

Resources