Selecting rows of a table from a column of another table - excel

I have a column in "table1.xlsx" with more than 200 IDs.
ID
21321
54646
48949
...
And another "table2.xlsx" with the IDs plus all the information about the people.
Name Surname ID City
John Wayne 54646 Madrid
Mary Jane 11111 Berlin
Julius Randle 21321 Rome
Peter Parker 48949 New York
I would like to extract the rows from "table2" that match with the IDs from "table1". There is an easy way?
"table3.xlsx"
Name Surname ID City
John Wayne 54646 Madrid
Julius Randle 21321 Rome
Peter Parker 48949 New York

Open table1.xlsx, table2.xlsx and table3.xlsx in Excel.
Go to Table1.xlsx. Select column A by clicking on A. Above that Column, you will see a box where cell number typically shows up. Click inside that and type in MyIDs.
Go to table2.xlsx. Create a new field called Matching IDs like so:
In Cell E2, type the formula:
=VLOOKUP(C2, table1.xlsx!MyIDs, 1, FALSE)
Hit enter. This formula means, take C2 (from table2) and find a matching row in table1.xlsx's named table called MyIDs (which is column A of table1). Then, choose the 1st column (which is the only column) from MyIDs. FALSE means do an exact match not an approximate match.
Click on E2. Copy it. Paste it into E3..En. You can drag to copy as well. That'll populate the formula in each cell in E column like this:
Click on sort and filter like this:
Click on Matching IDs dropdown and de-select #N/A
Highlight all rows and cells from the filtered data like so:
Copy. Go to table3.xlsx. Paste. Remove the extra column called Matching IDs at the end in table3.xlsx

Related

Finding the values that don't match from one sheet inside a few cells of another sheet

I have an excel document with two sheets sheet1 and sheet2. Sheet1:
ID number Name
123 John
321 Pete
Sheet2:
Book Comment Comment2 Comment3
Harry Potter My ID number is 123
TLOTR The book is ripped ID: 321
Dune Nice book ID is 999 None
I would like to search the column "ID number" from Sheet1 inside the text in the columns "Comment", "Comment2" and "Comment3" from Sheet2, and return the whole row from Sheet2 of the IDs that don't match.
So, in this case, the return would be:
Dune Nice book ID is 999 None
I have been trying the vlookup, I know how to search inside a text, and how to search inside multiple columns, but I don't know how to mix both processes
It looks like you have two problems.
Your ID or key to link the two spreadsheets together must match the data type. For example, one sheet you have ID number: with a list of only numbers. The other sheet you have text and numbers.
Try Xlookup instead.
Both columns you're using as the matching key has to be the same data type (letters or numbers)
First, use Text to columns (in tools, Data - text to columns) to separate your ID numbers from the rest of your text string in your sheet 2 columns that contain the Id numbers.
= Xlookup(CellwithfirstIDnumber,Columnfromsheet2tosearch, Column from sheet2tobring back, "no match")
Good luck

Excel: How to add a column from other sheet based on a key column?

I have 2 list. Both have a lot of column. I would like to insert a column from Sheet2 to Sheet1 based on a ceratin key column. Also sheet2 have much more rows than sheet1 so it ll be inserted only partly and still there ll be elements with no matches. For an example:
Sheet1:
Names ID Car Color
John 1 Audi Empty
Andy 4 Toyota Empty
Mike 3 BMW Empty
Tony 2 Suzuki Empty
Sheet2:
ID Cost Color
6 200 Blue
3 200 Red
4 300 Green
5 100 Red
1 50 Black
I would like to get the "color" from Sheet2 to Sheet1 by using the "ID". Using Excel 2010. I suspect I need INDEX+MATCH combination, but the examples I can find are not detailed and more simple so I coudn't figure out how to use them.
How about inserting this formula on Column D in the first row, then dropping the formula down:
=VLOOKUP(B1,Sheet2!$1:$1048576,3,FALSE)
Or to find the column that contains "Color", use Index Match Match, as follows:
=INDEX(Sheet2!$1:$1048576,MATCH(Sheet1!B2,Sheet2!A:A,0),MATCH("Color",Sheet2!$1:$1,0))
This will find the value in Column B in Sheet2 and give you the row number, then it will find the Column that contains "Color" and return the Column number, with those two numbers Index will return your color.

Splitting addresses into columns in Excel

I need help splitting addresses into columns in Excel.
Addresses in COLUMN A are written like:
601 W Houston St Abbott, TX 76621 United States
13498 US 301 South Riverview, FL 33578 United States
COLUMN B is actually a helper column. It contains only the city names from COLUMN A. My idea was to somehow match COLUMN B with COLUMN A and then all matches move to another column. That would separate City from the Address.State, Zip and Country I can use "split text to columns" since "comma" is delimiter. But I need help splitting address and the city.
There is a "comma" right after the city name, but some cities has more than one word in city name.
What I need to do is split the addresses like it's highlighted in green in the image below.
What is the best way to do that in Excel? What would be the formula for that?
We can use a quirk of LOOKUP to get this working.
=LOOKUP(1E+99,FIND(B$2:B$100,A2),B$2:B$100) in D2 will return the city based on searching for matches in column B. Note that this will need the full range of column B specified to be filled.
Then we can put =LEFT(A2,FIND(D2,A2)-2) in C2 to get the first part of the address.
The rest is easy if we can assume that the state, Zip and country are of constant length (if you've got any addressses outside the US then you'll need to alter this):
=LEFT(RIGHT(A2,22),3) in E2
=LEFT(RIGHT(A2,19),5) in F2
=RIGHT(A2,13) in G2
Since you already have City in Col B, just replace the city in A
D2 =SUBSTITUTE(A2,C2,"")
Column C Paste special values in Col C
Split Column C using comma.
Then split the Column D using "space". Assuming you have all records in US, you can add the country to all rows if required.
EDIT
I missed that the city name in the row does not correspond to the address. To match the city from the Master, you can use this array formula:
C2 =INDEX(B:B,MATCH(1,MATCH(""&$B:$B&"",A2,0),0))
Array formula must be confirmed with Ctrl-Shift-Enter.
However, this will find the first match. If you have cities Foster & Foster City in your master, Foster City wlll never be matched. So, sort the cities in descending order of length.
Once you have the City name matched you can follow the steps I gave earlier. Note that I have adjusted the formula to take into account the city name that has been matched by this new formula.
So, it is possible to get it done with the formula. It may not be the best way, but I got what I needed.
I've added a new sheet and named it "cities"
I moved the city list from sheet 1 to COL A in sheet "cities"
In sheet 1, B1 = =INDEX(cities!$A$1:$A$10000;LOOKUP(99^99;MATCH(RIGHT(TRIM(LEFT(SUBSTITUTE(A2;",";REPT(" ";255));255));ROW($A$1:$A$100));cities!$A$1:$A$10000;0)))
Then I've simply use SUBSTITUTE to remove city names from column A in Sheet 1: C1==SUBSTITUTE(A1, B1, "")
And that's it!

Excel look up value in array, return next value

I would like to look up a value in a range and return the value in the next row, but can't quite figure out how to do this. I especially would like to do this with formulas rather than VBA, and preferably with built-in formulas than custom (VBA) formulas, due to macro security issues.
I'm using Excel 2010. My workbook has two worksheets, "assessment" and "lookup". In lookup, I have lookup tables.
"lookup" looks something like:
Column A Column B Column C
1 Sales Engineering Manufacturing
2 Alice Bobbie Charlie
3 Dawn Edgar Frank
4 George Holly Isabel
In "assessment," I have some some drop downs from which users select one name from each column in "lookup." Based on some other criteria, I then rank these and create a new, sorted list (using INDEX() and MATCH()) that produce the selected name and corresponding column name a new sort order
Column A Column B
10 Engineering Edgar
11 Sales Alice
What I'd like is to return the name from the next row.
Column C
10 Holly
11 Dawn
But I'm having real trouble figuring out how to get there.
Assuming lookups is located at B2:D5 (change as required) and the result data is at F2:H3 (change as required) enter this formula in cell H2 then copy down.
=INDEX(
INDEX($B$2:$D$5,0,MATCH($F2,$B$2:$D$2,0)),
1+MATCH($G2,
INDEX($B$2:$D$5,0,MATCH($F2,$B$2:$D$2,0)),0))

Excel macro/formula - replace cell values if value does NOT appear in another column

I need help. I have a list of 20 names of certain consultants. I receive a new sheet daily with many names, and if one of them does not match with any of the 20 consultant names, I need to replace the cell value with "X".
E.g.
1. Consultant's list contains John and Mary.
2. Daily list contains 5 names: John, Steve, Dean, Mary and Sue.
3. I now want to replace all the cell which does NOT contain John and Mary with X (thus replace cell with names Steve, Dean and Sue with X)
Help will be appreciated
If your 20-name list is in ColumnA and the daily list in ColumnB each starting in Row1 then in Row 1 and copied down to suit:
=IF(ISERROR(MATCH(B1,A:A,0)),"X",B1)

Resources