I have the following table with four columns:

```
> x1 y1 x2 y2
> 1.2 800.5 1.4 200
> 2.6 850.3 7.6 300
> 3.1 900.1 9.2 400
> 4.6 949.9 5.5 500
> 5.2 999.7 10.2 600
> 6.7 1049.5 8.4 700
> 7.8 1099.3
> 8.3 1149.1
> 9.1 1198.9
> 10.1 1248.7
```

And I would like to have two more columns. One that contains a number that matches column x1 and x2 and the second one that has the difference between the values corresponding to the row match, like in the table below:

```
x1 y1 x2 y2 x3 y3 = y2-y1
1.2 800.5 1.4 200 1.2 (800.5-200)
2.6 850.3 7.6 300 5.2 (999.7-500)
3.1 900.1 9.2 400 7.8 (1099.3-300)
4.6 949.9 5.5 500 8.3 (1149.1-700)
5.2 999.7 10.2 600 9.1 (1198.9-400)
6.7 1049.5 8.4 700 10.1 (1248.7-600)
7.8 1099.3
8.3 1149.1
9.1 1198.9
10.1 1248.7
```

In words, column x3 should contain the value that matches both x1 and x2 (with a condition that the numbers should be closer e.g. 1.2&1.4) and y3 should contain the value that results from subtracting y1 and y2, corresponding to the matching rows. Both x3 and y3 have to be evaluated using x1,x2,y2 and y3.

So far I’ve been doing it manually, but it is exhausting for a long tables and I was thinking that there should be a method in excel, which I can’t figure our. I tried with

```
=INDEX(x1_array,MATCH(x2_array,y1_array,-1))
```

But it looks like an incomplete formula and I’m not even sure I’m doing it right, because of the differences in the column sizes. Can anyone help me with an idea on how to do this?

In case I wasn’t clear, I have sketched an example for reference:

Here is one way to solve it: see the below image with your data in col A-D.

First, you need a column E that finds the closest x1 to match every x2. Here’s a resource:

https://exceljet.net/formula/find-closest-match

Then, you need to MATCH the Y1 in col F. For example F2 is `=MATCH(E2,$A$2:$A$11,0)`

Finally, OFFSET the MATCH from the col that contains y2s and you’re done. In my example G2 is `=OFFSET($A$1,F2,1)`

and H2 is simply `=G2-D2`

.

Tags: excelexcel