# Excel Challenge

**URL:** https://boards.straightdope.com/t/excel-challenge/646236
**Category:** Factual Questions
**Created:** [January 6, 2013, 5:43am UTC](https://boards.straightdope.com/t/excel-challenge/646236 "2013-01-06T05:43:16Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![K364](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/k364/32/5_2.png) [@K364](https://boards.straightdope.com/u/K364)
#### Post date: [January 6, 2013, 5:43am UTC](https://boards.straightdope.com/t/excel-challenge/646236/1 "2013-01-06T05:43:16Z")

</div>

I want to find the row number of the nearest match, e.g. in the example below, Previous is the row# of the nearest matching value above.

It’s easy to find the nearest matching value _below_. But for _above_ I’m stumped.

```auto

Row	Fruit	Previous
---	-----	--------
2	Banana	#N/A
3	Apple	#N/A
4	Orange	#N/A
5	Grape	#N/A
6	Banana	2
7	Apple	3
8	Grape	5
9	Banana	6
10	Apple	7

```

---

<div class="post-metadata">

### Author: ![K364](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/k364/32/5_2.png) [@K364](https://boards.straightdope.com/u/K364)
#### Post date: [January 6, 2013, 6:44am UTC](https://boards.straightdope.com/t/excel-challenge/646236/2 "2013-01-06T06:44:36Z")

</div>

nm - I figured it out. The actual layout is below:

```auto

Row	Fruit	Prev	Next
2	Banana	#N/A	6
3	Apple	#N/A	7
4	Orange	#N/A	#N/A
5	Grape	#N/A	8
6	Banana	2	9
7	Apple	3	10
8	Grape	5	#N/A
9	Banana	6	#N/A
10	Apple	7	#N/A

```

You can take advantage of the “Next” column. In row 7 for example:  
Previous cell contains “=MATCH(ROW(B7),$D$1: D7,0)”  
Next cell contains “=MATCH(B7,B8:$B$11,0)+ROW(B7)”
