Forum Discussion

dmk1546's avatar
dmk1546
Copper Contributor
Feb 12, 2024

Vlookup

I have 2 spreadsheets that have 1 common field, Job #.  I want to be able to lookup/match job # from 1 spreadsheet but pull in the cost data from spreadsheet 1 to spreadsheet 2.  

2 Replies

  • dmk1546 

    I'd be glad to help you with your VLOOKUP task! Here's a comprehensive response incorporating the best aspects of both Response A and Response B, addressing their potential shortcomings, and tailored to your specific requirements:

    Scenario:

    You have two spreadsheets with a common "Job #" field. You want to use VLOOKUP to match a Job # in one spreadsheet and retrieve the corresponding cost data from the other spreadsheet.

    Solution:

    1. Identify Your Spreadsheets:

      • Clearly name and distinguish the two spreadsheets, e.g., "Spreadsheet A" and "Spreadsheet B."
      • Specify which sheet contains the Job # values you want to lookup (the "lookup sheet") and which one holds the cost data (the "cost sheet").
    2. Set Up the VLOOKUP Formula:

      • The syntax is VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup]).
      • lookup_value: The Job # you want to match. Enter the cell reference from the lookup sheet.
      • table_array: The range containing the Job # and cost data in the cost sheet. Include the sheet name if it's a different sheet.
      • col_index_num: The column number (within the table_array) that contains the cost data you want to retrieve. Count from 1, not 0.
      • [range_lookup]: Optional (defaults to FALSE). Set to TRUE for approximate matches, FALSE for exact matches. Use FALSE for best results unless you have specific reasons for approximate matches.
    3. Example Formula (assuming Job # in A1, cost in B2:B10, col_index_num 2, range_lookup FALSE):

      Excel=VLOOKUP(A1, SheetB!B2:B10, 2, FALSE)
      Replace A1 with the actual cell reference containing the Job # you want to look up.
      • Adjust SheetB!B2:B10 and 2 if your table_array and col_index_num differ.
    4. Copy and Drag Down:

      • Enter the formula in the first cell of your target column in the lookup sheet.
      • Copy the formula and drag it down to apply it to all Job #s.

    Example with Given Spreadsheets (assuming the provided information is still accurate):

    If the Job # is in sheet1!A2 and the cost is in sheet2!B2:B10 (column B), the formula would be:

    Excel=VLOOKUP(sheet1!A2, sheet2!B2:B10, 2, FALSE)
    Remember:
    • VLOOKUP assumes the lookup column (first column in table_array) is sorted in ascending order for efficient exact matches. If data isn't sorted, use TRUE for range_lookup, but be cautious of potential mismatches.
    • Consider using absolute or relative references depending on where you plan to copy the formula.

    I hope this comprehensive response empowers you to effectively use VLOOKUP and combine data from your two spreadsheets!

     
     
  • dmk1546 

    Let's say job numbers are in A2:A100 and cost amounts in D2:D100 on the first sheet.

    With a job number in B2 on the second sheet:

    =IFERROR(VLOOKUP(B2, 'first sheet'!$A$2:$D$100, 4, FALSE), "")

    Replace first sheet with the real name of that sheet. The number 4 specifies that the return value should be from the 4th column of the lookup range.

    If you have Microsoft 365 or Office 2021:

    =XLOOKUP(B2, 'first sheet'!$A$2:$A$100, 'first sheet'!$D$2:$D$100, "")

    The formulas can be filled down.