Yes, you can merge data from two columns using a formula. The most reliable method is the VLOOKUP function, which searches for a value in one column and returns a result from another. This allows you to combine customer lists, update pricing, or merge data from separate sources without retyping.
What You'll Need
- A computer with Microsoft Excel installed (2016, 2019, 2021, or Microsoft 365). The interface is largely the same across these versions.
- A spreadsheet with at least two columns of data that share a common identifier, such as an ID number, name, or SKU.
Step-by-Step
- Identify your lookup and return columns. Open your workbook and locate the two columns you want to combine. For example, Column A might contain a list of Customer IDs, and Column B might contain the corresponding Customer Names. You will use Column A to find the data in Column B.
- Prepare your target cell. Click on the cell where you want the matched data to appear. This cell should be in the same row as the data you are trying to find. If you want to match data from Column A to Column D, click on cell D2 (assuming your data starts in row 2).
- Start the VLOOKUP formula. Type an equals sign (
=), followed byVLOOKUP. Excel will autocomplete the function name. Press Tab to select it. - Enter the lookup value. The first argument asks for the value you want to find. Click on the cell containing the data you want to match (e.g., the ID in cell A2). Alternatively, you can type the value directly if it is static. Close this argument with a closing parenthesis
). - Enter the table array. The second argument is the range of cells that contains the data you want to retrieve. Highlight the entire block of data that includes both your lookup column and your return column. For example, highlight A2:B100. Ensure the first column of this range is the same data you are searching for (Column A). Close this argument with a comma
,. - Specify the column index number. The third argument asks which column number, within the table array, contains the value you want to return. Count the columns in your table array from left to right. If you selected A2:B100, Column A is 1 and Column B is 2. Since we want the name from Column B, type
2. Close this argument with a closing parenthesis). - Set the match type to FALSE (Exact Match). The fourth argument determines how Excel searches for the lookup value. Type
FALSE(or0) to ensure Excel finds an exact match. This is the default behavior for most VLOOKUP requests, but it is important to specify it explicitly to prevent errors. Press Enter. - Copy the formula down. With the formula entered correctly, double-click the small square handle in the bottom-right corner of the cell. This will automatically copy the formula to all rows in your dataset, matching the corresponding data for every entry.
Common Mistakes
Misunderstanding the column index number is the most frequent error. The index number counts from the leftmost column of your selected table array, regardless of where the lookup value actually sits. If you select A2:C50 as your table array but the lookup value is in Column C, you cannot use a VLOOKUP to find it. You must reorder your columns so the lookup value is in the first column of the selection. Furthermore, using TRUE (approximate match) instead of FALSE can cause unexpected results; it is safer to always use FALSE unless you are specifically looking for a value within a sorted list of ranges.
Tips
Ensure your data is clean before matching. Leading or trailing spaces can prevent a match from working. You can use the TRIM() function to remove extra spaces from your data. Also, keep in mind that VLOOKUP is case-insensitive; Apple and apple will be considered the same value. If you need a case-sensitive match, the XLOOKUP function (available in Excel 365 and Excel 2021) is a better choice, as it offers a [match_mode] argument to handle case sensitivity and does not require you to count column numbers.
Troubleshooting
If your formula returns #N/A, it means the lookup value was not found. Check the spelling of the lookup value and the data in the table array. Ensure there are no extra spaces or hidden characters. If you get #REF!, you likely selected a column index number that is too high for your table array. Check the count of columns in your selection and adjust the number accordingly.
Frequently Asked Questions
Can I match data from the right column to the left column?
No, standard VLOOKUP cannot do this. It always searches the leftmost column of the selected range. To match data from the right to the left, you must reorder your columns or use a different function like INDEX and MATCH.
What does the #VALUE! error mean?
This error usually occurs if your lookup value is the wrong data type. For example, if you are trying to match a number against a text-formatted number, the match will fail.
How do I update the data if the source changes?
Once the formula is set up, it will automatically update whenever the source data changes, provided the row structure remains consistent.
Is there a limit to how many rows I can match?
No, Excel can handle millions of rows. Performance may slow down significantly with very large datasets, but the function will still work.
Can I use VLOOKUP across different sheets?
Yes. When entering the table array argument in step 5, simply click on the tab of the other sheet and highlight the relevant range. The formula will automatically include the sheet reference, such as 'Sheet2'!A2:B100.