I have my data as follows :
---------input------ ---output--- data1 data1 abcd data1 abcd data2 data5 efgf data2 nopf data3 data3 hijf data3 hijf data4 data7 klmf data4 data5 data2 nopf data5 efgf data6 .... .... data6 data7 .... .... data7 klmf data8 .... .... data8
Explanation:
- Column1 has all elements.
- Col2 is subset of col1.
- Col3 is respective values of Col2. (key-value pairs)
- Col4 and col5 is the output I want.
Here, I need to copy the Col3 values if Col2 key is present in Col1.
How do I achieve this?
If I understand your question correctly, you can use the vlookup function to lookup the “keys” in column 3 and return the values you want in column five.
Assume column one starts in A2, column 2 in B2, column three in C2, column four in D2 (and is just pasted from column 1) and column five in E2, which is where you’ll put the formulas to look up your values. The data are in rows 2 through 9.
I’m assuming that the “….” characters that you show in columns B and C are actually in your data.
The formula in cell E2 should be:
You would copy the formula down through cell E9.