I need some help with an excel formula or format that can help me with the following:

# TABLE 1

```
(Row) |(a) ID | (b)FROM | (c) TO | (d) VALUE
(1) 123 0 1 50
(2) 123 1 2 50
(3) 123 2 3 50
(4) 123 3 4 50
(5) 123 4 5 60
(6) 123 5 6 60
```

# TABLE 2

```
(Row) |(a) ID | (b)FROM | (c) TO | (d) VALUE
(1) 123 0 4 50
(2) 123 4 6 60
```

So table one has been incremented to 1 (from and to) whereas table two contains ranges with the values. The incremented values in table 1 should equal the values in table two if the range in table one falls within the range from table 2.

# OUTPUT

```
(Row) |(a) ID | (b)FROM | (c) TO | (d) VALUE
(1) 123 0 1 50 TRUE
(2) 123 1 2 50 TRUE
(3) 123 2 3 50 TRUE
(4) 123 3 4 50 TRUE
(5) 123 4 5 60 TRUE
(6) 123 5 6 60 TRUE
```

Basically ID’123′ has a value of 50 for the increments from 0 to 4 and value of 60 for the increments from 4 – 6 and as per TABLE 2 0-4 = 50 and 4-6 = 60 therefore the statement should be TRUE.

```
=IF(AND(A1=table2!a:a, table1!B1>=table2!b:b,table1!a1<table!B:B),IF(table1!d2=table2!d:d, TRUE,FALSE))
```

It might be with the way excel deals with ranges etc?

I like the answer from @tigeravatar (credits to him/her) but if you haven’t got a ordered list I have created something below that doesn’t need that. If table two is not ordered by ID number you could use this formula in cell E2 and copy down:

```
=IFERROR(IF(B2>=INDEX(table2!$A:$D,MATCH(D2,table2!$D:$D,0),2),IF(C2<=INDEX(table2!$A:$D,MATCH(D2,table2!$D:$D,0),3),IF(A2=INDEX(table2!$A:$D,MATCH(D2,table2!$D:$D,0),1),TRUE,FALSE))),FALSE)
```

This does essentially the same but with an AND statement

```
=IFERROR(IF(AND(A2=INDEX(table2!$A:$D,MATCH(D2,table2!$D:$D,0),1),B2>=INDEX(table2!$A:$D,MATCH(D2,table2!$D:$D,0),2),C2<=INDEX(table2!$A:$D,MATCH(D2,table2!$D:$D,0),3)),TRUE,FALSE),FALSE)
```

### Answer：

On table1, cell E2, use this formula and copy down:

```
=D2=VLOOKUP(B2,INDEX(table2!B:B,MATCH(A2,table2!A:A,0)):INDEX(table2!D:D,MATCH(A2,table2!A:A,0)+COUNTIF(table2!A:A,A2)-1),3)
```

Tags: excelexcel