To achieve this task, you can use a combination of Excel formulas, specifically using VLOOKUP or INDEX/MATCH to find matching items between the two lists and then calculate the differences. Here's a step-by-step guide on how to do it. I'll assume your lists are in columns A and B for the first list (item and quantity, respectively) and columns D and E for the second list.
Step 1: Prepare Your Data
Let's say your data is structured as follows:
- List 1 is in columns A and B (Item and Quantity).
- List 2 is in columns D and E (Item and Quantity).
- You want to create a third list that shows the differences in quantities for items that appear in both lists, and you want this list to be in columns G and H.
Step 2: Identify Common and Unique Items
-
List all unique items: First, you need to compile a list of all unique items from both lists. You can do this by copying both item lists (columns A and D) into a new column (say, column F), removing duplicates, and then sorting the list.
- To remove duplicates, select the range, go to
Data > Remove Duplicates.
- To sort, select the range, go to
Data > Sort & Filter > Sort A to Z.
-
Alternative: Use a formula to list unique items. If you have Excel 365 or Excel 2021, you can use the UNIQUE function to list unique items directly:
- Assuming your items are in A2:A100 and D2:D100, you can use:
=UNIQUE({A2:A100;D2:D100}) in a new column (like F2). Press Ctrl+Shift+Enter if you're not using Excel 365.
Step 3: Calculate Quantity Differences
-
Use VLOOKUP or INDEX/MATCH to find quantities:
- For each item in your compiled list (column F), use
VLOOKUP or INDEX/MATCH to find its quantity in both lists and then calculate the difference.
-
Formula for Quantity Difference:
- Assuming F2 is the item, you can use the following formula in G2 to get the quantity difference:
=IFERROR(VLOOKUP(F2, B:C, 2, FALSE) - VLOOKUP(F2, E:F, 2, FALSE), "Not in Both Lists")
- Or, using
INDEX/MATCH which is more flexible:
=IFERROR(INDEX(B:B, MATCH(F2, A:A, 0)) - INDEX(E:E, MATCH(F2, D:D, 0)), "Not in Both Lists")
- If you want to directly show the quantity if an item is not in both lists, you can adjust the formula to check if the item exists in both lists and return the quantity from the list it exists in.
-
Drag the formula down to apply it to all items in your compiled list.
Step 4: Adjust the Formula for Your Needs
- If you want to directly show the quantity for items that are only in one list, you can modify the formula to check for errors in
VLOOKUP or MATCH and return the available quantity.
Example Using INDEX/MATCH
Let's say you have the following data:
-
List 1 (A:B):
- A2:A4 = {"Item1", "Item2", "Item3"}
- B2:B4 = {10, 20, 30}
-
List 2 (D:E):
- D2:D4 = {"Item1", "Item3", "Item4"}
- E2:E4 = {5, 35, 40}
In F2, you have "Item1". The formula to calculate the difference for "Item1" using INDEX/MATCH would be:
=IFERROR(INDEX(B:B, MATCH(F2, A:A, 0)) - INDEX(E:E, MATCH(F2, D:D, 0)), IFERROR(INDEX(B:B, MATCH(F2, A:A, 0)), INDEX(E:E, MATCH(F2, D:D, 0))))
This formula first tries to calculate the difference. If it fails (because the item is not in both lists), it then tries to return the quantity from either list where the item exists.
Finalizing
After applying these steps, you'll have a third list that shows the differences in quantities for items that appear in both lists and the quantities for items that are unique to one list. You can further adjust the formulas based on your specific needs or data structure.