[excel] How to import data from one sheet to another

I have two different work sheets in excel with the same headings in in all the row 1 cells(a1 = id, b1 = name, c1 = price). My question is, is there a way to import data(like the name) from 1 worksheet to the other where the "id" is the same in both worksheets.

eg.
sheet 1                             sheet2
ID      Name       Price            ID        Name        Price
xyz     Bag        20               abc                     15
abc     jacket     15               xyz                     20

So is there a way to add the "Name" in sheet 1 the "Name" in sheet 2 where the "ID" in sheet 1 = "ID" in sheet 2?

Without coping and pasting of course Thanks

This question is related to excel worksheet-function vlookup

The answer is


Saw this thread while looking for something else and I know it is super old, but I wanted to add my 2 cents.

NEVER USE VLOOKUP. It's one of the worst performing formulas in excel. Use index match instead. It even works without sorting data, unless you have a -1 or 1 in the end of the match formula (explained more below)

Here is a link with the appropriate formulas.

The Sheet 2 formula would be this: =IF(A2="","",INDEX(Sheet1!B:B,MATCH($A2,Sheet1!$A:$A,0)))

  • IF(A2="","", means if A2 is blank, return a blank value
  • INDEX(Sheet1!B:B, is saying INDEX B:B where B:B is the data you want to return. IE the name column.
  • Match(A2, is saying to Match A2 which is the ID you want to return the Name for.
  • Sheet1!A:A, is saying you want to match A2 to the ID column in the previous sheet
  • ,0)) is specifying you want an exact value. 0 means return an exact match to A2, -1 means return smallest value greater than or equal to A2, 1 means return the largest value that is less than or equal to A2. Keep in mind -1 and 1 have to be sorted.

More information on the Index/Match formula

Other fun facts: $ means absolute in a formula. So if you specify $B$1 when filling a formula down or over keeps that same value. If you over $B1, the B remains the same across the formula, but if you fill down, the 1 increases with the row count. Likewise, if you used B$1, filling to the right will increment the B, but keep the reference of row 1.

I also included the use of indirect in the second section. What indirect does is allow you to use the text of another cell in a formula. Since I created a named range sheet1!A:A = ID, sheet1!B:B = Name, and sheet1!C:C=Price, I can use the column name to have the exact same formula, but it uses the column heading to change the search criteria.

Good luck! Hope this helps.


Examples related to excel

Python: Pandas pd.read_excel giving ImportError: Install xlrd >= 0.9.0 for Excel support Converting unix time into date-time via excel How to increment a letter N times per iteration and store in an array? 'Microsoft.ACE.OLEDB.16.0' provider is not registered on the local machine. (System.Data) How to import an Excel file into SQL Server? Copy filtered data to another sheet using VBA Better way to find last used row Could pandas use column as index? Check if a value is in an array or not with Excel VBA How to sort dates from Oldest to Newest in Excel?

Examples related to worksheet-function

WorksheetFunction.CountA - not working post upgrade to Office 2010 Excel formula to get cell color How to find the first and second maximum number? IF statement: how to leave cell blank if condition is false ("" does not work) Use string value from a cell to access worksheet of same name I want to compare two lists in different worksheets in Excel to locate any duplicates Converting a string to a date in a cell Refer to a cell in another worksheet by referencing the current worksheet's name? Have Excel formulas that return 0, make the result blank Convert date field into text in Excel

Examples related to vlookup

Check if an excel cell exists on another worksheet in a column - and return the contents of a different column "Unable to get the VLookup property of the WorksheetFunction Class" error Comparing two columns, and returning a specific adjacent cell in Excel VLook-Up Match first 3 characters of one column with another column Combining COUNT IF AND VLOOK UP EXCEL Excel- compare two cell from different sheet, if true copy value from other cell Vlookup referring to table data in a different sheet Excel - find cell with same value in another worksheet and enter the value to the left of it Remove #N/A in vlookup result Excel vba - convert string to number