Excel: Sort column to match values of another column - excel

I've got a problem with an excel sheet with 4 columns where two columns rely on each other because Column A is the name and column B is the quantity, the same thing with columns C and D.
Table
==========================================
A B C D
Apple 54 Banana 12
Peanut 6 Pineapple 4
Cranberry 112 Cherry 40
Cookie 3 Peanut 4
Banana 2 Cranberry 5
Peach 3 Almond 10
Cherry 5
Cheese 10
What I want to get is that each content of column C with the quantity in column D will be placed in the same row as their matching part in column A so I can compare the quantities between B and D. All the values with no matching partner should be placed at the bottom or just with an empty table, so I know there is no match.
Example how it should look like:
Table
==========================================
A B C D
Apple 54
Peanut 6 Peanut 4
Cranberry 112 Cranberry 5
Cookie 3
Banana 2 Banana 12
Peach 3
Cherry 5 Cherry 40
Cheese 10
Almond 10
Pineapple 4

This should solve your problem: =VLOOKUP(C2;$A$2:$B$9;2;TRUE)
You simply add this as a column "E" in your spreadsheet and drag it down then you can compare the values.

Col A remains as it is.
Col B remains as it is.
Col C moves to Col E.
Col D moves to Col F.
New Col C, Cell C1 = =IFS(AND(A1<>"",(COUNTIF($E$1:E, A1)=1)=TRUE),A1,AND(A1<>"",(COUNTIF($E$1:E, A1)=1)=FALSE),"",A1="",ArrayFormula(INDEX($E$1:E,SMALL(IF(ISERROR(MATCH($E$1:E,$A$1:A,0)),(ROW($E$1:E)-MIN(ROW($A$1:A))+1),""),SUM(ROW(1:1)-COUNTA($A$1:A1))))))
Copy this down from C1
New Col D, Cell D1 = =IF(C1="","",VLOOKUP(C1,$E$1:F,2,FALSE))
Note: I wrote this in Google sheets, So when I type ctrl + shift + enter it coverts it into ArrayFormula(). You will need to do an array formula the excel way - ctrl + shift + enter and remove the ArrayFormula().
Feel free to view this in a sheet - https://docs.google.com/spreadsheets/d/10hygbPyzj7L1u77izejoeGriaquoZ_omp49pCJ2U7uE/edit?usp=sharing
If you want to export the sheet. Right click the "sheet 1" tab, go to "copy to" and "new spreadsheet"
Any questions, let me know :)

Related

How to delete duplicate rows and keep the nth occurrence on Excel?

In Excel I want to delete duplicate rows but I want to have some preferences for what duplicate occurrence to keep. As in Excel while removing duplicates it by default keeps the first occurrence. Is there any way to keep the 2nd or 3rd occurrence?
For example:
a Apple
a Banana
a Cherry
b Apple
b Banana
b Melon
c Apple
c Cherry
c Melon
By default if I remove duplicate, it would be like this:
a Apple
b Apple
c Apple
But is there a way to achieve this
a Banana
b Banana
c ?
As the C doesn't have banana, we can keep this blank, or any default value.
To always keep the second occurrence,
SORT the data,
MATCH the elements among itself to get the first occurrence,
Subtract the matched row number from actual row number and if it's not 1, filter it out.
Input:
Duplicates
Helper column
a
Apple
a
Cherry
b
Apple
c
Apple
c
Cherry
b
Banana
b
Melon
a
Banana
c
Melon
Formula:
=FILTER(SORT(A1:B9,1,1),ROW(A1:A9)-MATCH(SORT(A1:A9),SORT(A1:A9),0)=1)
Output:
Second occurrence
Helper column
a
Cherry
b
Banana
c
Cherry
see:
=FILTER(A1:B, COUNTIFS(A1:A, A1:A, ROW(A1:A), "<="&ROW(A1:A))=2)
for 3rd occurrence change 2 to 3

Excel - Match 2 columns and paste result from appending cell

From the table below, I want to match 'COLUMN A' and 'COLUMN C', when the match happens, the value from 'COLUMN D' should be pasted in 'COLUMN B'.
Column A Column B Column C Column D
AB FAST AE APPLE
CD RAINBOW EF BANANA
EF BANANA AG CARROT
GH HAMSTER ET DOG
WE EYE
AB FAST
GF GOOGLE
GH HAMSTER
HJ JOKER
ER LION
CD RAINBOW
Expected result:
COL A COL C COL D COL B
'AB' matched 'AB' extract value from 'FAST' and paste in FAST
Select your table including the headers, click insert and then click table. Paste the following formula in COLUMN B INDEX(Table1,MATCH([#[Col A]],[Col C],0),4)

A function that will lookup a reference

Before I get started thanks for taking your time and helping.
This is what my worksheet looks like:
Row # B C D E F
2 1 Product 1 B2 B3 B4
3 2
4 6
5 1 Product 2 B5 B6
6 5
7 4 Product 3 B7
I was trying to follow this formula: (The best answer one or green check mark) return values from multiple matching rows
I got all the way to the =IFERROR(INDIRECT(lookups!H5),"") but can not get this to work.
What I am tying to do is order the numbers in Column B to go to the right of the product. Which I was able to get the column it is in (B) and the row number it is in (B2). I would like to change the value (B2) to the number that is there.
I would like it to look like this:
Row # C D E F
2 Product 1 1 2 6
3
4
5 Product 2 1 5
6
7 Product 3 4
If someone could help explain this to me or find a better way that would be great.
Not sure what is to happen to columnB but if you replace B with "="B throughout columns D:F then select each of these in turn and apply Text to Columns with Tab as the delimiter the 'cell references' convert to formulae referring to the values in B. If you want to delete columnB copy D:F and Paste Special, Values over the top.

miss and match on excel

I'm not even sure if what i want to happen is possible but here it is :
So i have a list on column A and another on column B. Say, column A has apples, bananas, eggs... Then column B has apple pies, banana pies, egg pies...on column C, I want excel to tell me that apples and apple pies match and bananas and banana pies match, and so on. Then tell me if they don't match at all. I want it so that even if i want 2 values from column A to match with a value in column B. For example aside from apples there could also be pears in column A but i would still want pears to return a match value with apple pies. I hope this is not too confusing
... Thanks in advance!
Ok, I am going to give you multiple answers because I am not sure what the question is. If Gary's Student's comment is the right answer and you just want to match the contents then all you need to do is put this in C2 and copy it to every row:
=IF(ISERROR(FIND(A2,B2)),"no match","match")
But if your comment about 1-2=bad, 3-8=good and 9-10=very good is what you really want then all you need to do is put this in C2 and copy it to every row:
=IF(B2=CHOOSE(A2,"bad","bad","good","good","good","good","good","good","very good","very good"),"match","no match")
What that does is change the number in column A to be the equivalent string and then match that string against column B.
But if you are looking for a solution that works for both things then you need a dictionary. If you use ALL the piossible values from B as the keys and each matching value from A as the values then you can call MATCH twice and see if the value belongs to the key.
So for example the dictionary for the pie example might look like this (notice that pies can have more than one ingredient):
E F G H I J K
1 Key Value 1 Value 2 Value 3 Value 4 Value 5 Value 6
2 lemon pie lemon egg
3 apple pie apple pear
4 pear pie pear
5 egg pie egg
And the dictionary for the bad and good example would look like:
E F G H I J K
1 Key Value 1 Value 2 Value 3 Value 4 Value 5 Value 6
2 bad 1 2
3 good 3 4 5 6 7 8
4 very good 9 10
Then you can stick this in C2 and copy it to every row:
=IF(ISNA(MATCH(A2,OFFSET(F$1:O$1,MATCH(B2,E$2:E$20,0),0),0)),"no match","match")
What this does is look up the value in column B in the dictionary and find what row it is in. Then it offsets F$1:O$1 by that many rows so that the range for the outside match is the correct list of incgredients. Then it matches the value in column A by the list of ingredients that the offseted inside match produced.
Maybe some screenshots will help:

Excel - Combine multiple columns into one column 3

What is the formula that we can use in Microsoft Excel to get the result of the value summation from string column A and string Column C if they are the same? Column B and Column D are both the number that assign to its respective column which is Column A and Column C. For example “orange” holds the value 6 (in Column B) for Column A while in Column C “orange” hold the value 2 (in column D).Final results should show the summation of 6+2=8 (in Column F) for string ‘Orange’ (Column E).
Thank you
Lupe
If you have this table:
A B C D
orange 1 orange 6
apple 2 apple 7
grapes 3 carrot 8
carrot 4 melon 9
And you want to search in column C for each of the A column values, you should use this in column E: (for E2, and drag down)
=IFERROR($B2+VLOOKUP($A2,$C$2:$D$5,2,FALSE), 0)
make sure to change $C$2:$D$5 to your range (in both places).
A B C D E
orange 1 orange 6 7
apple 2 apple 7 9
grapes 3 carrot 8 0
carrot 4 melon 9 12

Resources