How to find and match data in Excel - excel

I have an Excel file which contains two sheets, one holds a list of specific usernames (say in column A) and the other one holds the complete list of usernames (column A) and also the cities (column B).
I need a formula to match usernames between these two sheets and then have the related cities next to the usernames at the first sheet, for example in column B of it.
Here is what I tried at column B of the second sheet but didn't succeed:
=VLOOKUP(A1&"", Sheet1!$A$1:$B$1000, 2, FALSE)
I've also replaced the first argument with A1+0 and also the second one without any $ signs if it helps anyway.
Here is the entire of my original formula:
=IF(ISERROR(VLOOKUP(B1&"", Sheet1!$M$1:$N$1170, 13, FALSE)), VLOOKUP(B1&"", Sheet1!$N$1:$V$1170, 22, FALSE), VLOOKUP(B1&"", Sheet1!$M$1:$N$1170, 13, FALSE))
It suppose to take the username from column B of Sheet2 (the first one described above which only has the specific list of usernames) and search for the match in column N of Sheet1 (the second described sheet which has username and city inside), then return the value of city which is placed on column M but if it has a #N/A error (which is probable), return the V column instead which also holds the city name on the rows those have no city name in their M column.

You could use a VLOOKUP to look up the items from B in the list of A. If it doesn't find a match, VLOOKUP will return #N/A. You could also combine this with an IF statement so that if it's missing, it'll give you some message. For example, in C1 enter
=IF(ISNA(VLOOKUP(B1, $A$1:$A$1957, 1, FALSE )), "MISSING", "MATCHED!")
and copy/paste this formula all the way down your column of "B" figures to check.
this will start by looking up B1 in the range of A1:A1957. If it does not find a match it will return NA. Then we combine this with an IF statement so that IF VLOOKUP results in NA, we give a message of "MISSING". If it's not NA then there it means we found a match, so we give a message of "MATCHED!".
obviously you can change the missing/matched message to whatever you like.
best online MBA

A few comments:
1) Why: B1&"", ? Try: B1,
2) Both the lookup column 13 and 22 can't be possible if the lookup table is only 2 column's. So these values should either be 2, or you need to expand the column range up to the amount you wish to retrieve the data from.
You need to count the amount of columns starting from the first lookup column in your range so ... if the data to retrieve from column M to column N is in column N, then this should be 2. For N up to V, this should be 9. TRY:
=IF(ISERROR(VLOOKUP(B1&"", Sheet1!$M$1:$N$1170, 2, FALSE)), VLOOKUP(B1&"", Sheet1!$N$1:$V$1170, 9, FALSE), VLOOKUP(B1&"",
Sheet1!$M$1:$N$1170, 2, FALSE))

In the original formula (from second part), your range starts from the wrong column: should start with the column which has the matching lookupvalue. I assume column A. From column A, it's 22 columns to V, and 13 columns to N. The correct formula should then be:
=IF(ISERROR(VLOOKUP(B1&"", Sheet1!$A$1:$N$1170, 13, FALSE)), VLOOKUP(B1&"", Sheet1!$A$1:$V$1170, 22, FALSE), VLOOKUP(B1&"", Sheet1!$A$1:$N$1170, 13, FALSE))
If for example you have the matching username in for example B, the formula should be:
=IF(ISERROR(VLOOKUP(B1&"", Sheet1!$B$1:$N$1170, 12, FALSE)), VLOOKUP(B1&"", Sheet1!$B$1:$V$1170, 21, FALSE), VLOOKUP(B1&"", Sheet1!$B$1:$N$1170, 12, FALSE))

Related

How to do Multi Criteria Match Index Function

I am trying to use Index/Match function to populate Column B of Sheet 1 based on the data in Sheet 2.
Sheet 1:
Below is how the sheet 2 looks like. Row 1 contains the line number. Column B and Column C belong to Line 1, and Column D and E belong to Line 2, etc.
I need to match the Project ID first. Then match the Activity Line # (Column C of sheet 1 with B1:G1 of sheet 2), then find the corresponding Activity #.
For example, on sheet one, it is asking for Activity # of Project 0000002/Activity Line 2, which should be "ES" based on the sheet 2.
So, ideally, the result should look like below
This is what I have for now, but it’s giving me a #REF! error…
=IFNA(INDEX('Sheet2'!$B:$G, MATCH('Sheet1'!C2, INDEX('Sheet2'!$B$1:$G$1, MATCH('Sheet1'!A2, 'Sheet2'!$A:$A,0),0),0)),"")
Use:
=IFERROR(INDEX('Sheet2'!$B:$G,MATCH(A2,'Sheet2'!$A:$A,0),MATCH(C2,'Sheet2'!$B$1:$G$1,0)),"")

How to sort through table using a sublist of criteria in excel

I have a table of data with 5 columns A B C D E. Under column A are values ranging from 1 to 1000 (with repeats and no blanks), and columns B to E have data relating to that number. How do I sort this table if I have a predefined list in mind, let's say I want to see only the data relating to numbers 5, 8, 15, 100, 150...etc. How would I be able to sort it with a custom list?
Let me know if further clarification is needed.
I found a solution after tinkering around.
I went into into data > advanced and selected my whole table ($A$1:$E$2000) as the "List range" and put down my list of criteria (the numbers I'm sorting for from column A) in column F as the "Criteria range". You need to enter A's header as the header of your list of criteria or else it won't work.

Find values that are not in every row

I have a spreadsheet that contains users in each column. Below each user lists groups that they are in.
I want to highlight values that are not in every column.
If a user is part of a group that everyone is a part of, that group would not be highlighted.
If there was even one person who wasn't part of that group as well, that group would be highlighted.
Example.
Say there are 3 columns: A, B, C.
Column A has values 1, 2, 3, 4, 5 listed below it. Each number in a different row
Column B has values 1, 2 ,4, 5 listed below it.
Column C has values 1, 2, 4, 6, 7 listed below it.
In this example
In Column A, 3 and 5 would be highlighted.
In Column B, 5 would be highlighted.
In Column C, 6 and 7 would be highlighted.
Because each of those numbers are not listed every column.
So, you can do this using Conditional Formatting using the following logic:
Just for the sake of example, suppose your data is in the range A1:H20 with, as you said, each column being a new user and the first row A1:H1 being user names.
What this tells us:
COUNTA($A$1:$H$1) = Number of users
COUNTIF($A$1:$H$20,A2) = Number of times the value in A2 appears in your dataset
Therefore if COUNTIF($A$1:$H$20,A2) < COUNTA($A$1:$H$1), that means the value in A2 does not appear in each column (otherwise they woud be equal). (Also note that this is based on the assumption that you can't have a value appearing twice in a given column!).
At this point, it's a simple conditional formula.
Hope this explains it well enough.

How to match two columns in Excel

i am trying to Match two columns, say column A (2, 3, 4, 5, 5, 6, 7) and column B (2, 3, 4, 5, 6, 7) using IF(ISERROR(MATCH(A1,$B$1:$B$8,0)),"",A1).
The formula matches all values correctly but for the fives. It does match both 5's in column A with the single 5 in column B. whereas I expected it to pick one 5 in column A and matching with that in column B leaving the other 5 pending. Anyone have an alternative formula to the one above? Thanks
Assuming you are copying the formula down in another column, you could use COUNTIF to see if the number has already occurred in that column:-
=IF(OR(ISERROR(MATCH(A2,$B$2:$B$7,0)),COUNTIF(C$1:C1,A2)),"",A2)
(I am adding headers and starting in row 2).

Identify matching numbers and then imput a value from a different column

I have two sheets, Sheet1 and Sheet2. Sheet1 has a list of company names in column A, Revenue in column B and a unique number identifier in column D (also seen as "unique #forAAA in Sheet2). In Sheet2, I pulled a list from Hoovers, and the format comes up something like below (so this format should not be changed).
Column A B C D
Company Name Place Type of Comp Revenue
1 AAA US HQ 10.0 M
2 unique #forAAA
3 BBB India Branch 5.0 M
4 unique #forBBB
What I'd like to do is match the unique number for each company between Sheet1 and Sheet2 and then put the revenue # from Sheet2 into column B of Sheet1 which corresponds to the correct #. I'm pretty lost here, so any help or ideas would be great. Thanks for your help!
Because the unique identifier is on a different row than the result to be returned, you can use a variation using INDEX and MATCH:
=INDEX(Sheet2!D:D, MATCH(D2, Sheet2!A:A, 0)-1)
INDEX will return the value within range Sheet2!D:D on row MATCH(D2, Sheet2!A:A, 0)-1.
MATCH(D2, Sheet2!A:A, 0) will give you the row number where the unique ID is found, then -1 to get the row number of the revenue amount.
EDIT: As per comment, to remove the M, you can use this:
=TRIM(SUBSTITUTE(INDEX(Sheet2!D:D, MATCH(D2, Sheet2!A:A, 0)-1),"M",""))
I would put the unique value in a column inserted before A (would be the new column A) instead of putting it below each row. Then, in the other sheet I'd put the VLOOKUP like this:
=VLOOKUP(D2,Sheet2!A:E,5,0)
That should return the value in column E (column D before the column insertion, i.e. revenue for the unique company identifier).
Note that the third argument in the vlookup function is the number of the column you want to be retrieved, so the range defined in the second argument (Sheet2!A:E) should contain that column.

Resources