# Excel query

**URL:** <https://boards.straightdope.com/t/excel-query/422942>\
**Category:** Factual Questions\
**Created:** [October 16, 2007, 8:38pm UTC](https://boards.straightdope.com/t/excel-query/422942 "2007-10-16T20:38:56Z")\
**Posts on this page:** 3\
**Page:** 2

<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:** [October 18, 2007, 12:25am UTC](https://boards.straightdope.com/t/excel-query/422942/21 "2007-10-18T00:25:04Z")

</div>

Lionne,

VLOOKUP is the way to go as you’ve discovered. And it MAY help with the companies being assigned a range of (bag?) numbers.

Research the use of the “range\_lookup” parameter in VLOOKUP (it’s the FALSE in the fourth position). If set to TRUE, it will the matching row or an “approximate” match - in the table below a VLOOKUP(A1, Companies, 2, TRUE) where A1=2 will return “ABC”

```auto

 1 ABC
11 DEF
21 GHI

```

For this to work, the table must be sorted in ascending order.

---

<div class="post-metadata">

**Author:** ![Sofaspud](https://avatars.discourse-cdn.com/v4/letter/s/8491ac/32.png) [@Sofaspud](https://boards.straightdope.com/u/Sofaspud)\
**Post date:** [October 18, 2007, 12:28am UTC](https://boards.straightdope.com/t/excel-query/422942/22 "2007-10-18T00:28:29Z")

</div>

[QUOTE=K364]  
For this to work, the table must be sorted in ascending order.  
[/QUOTE]

True, but also important to note is that it will find matches even where there aren’t supposed to be any.

For example, if Company A has 23 - 25, and Company B has 28 - 34, but nobody has 26 - 27, it will still return either Company A or Company B when 26 or 27 is entered (depending on the range\_lookup setting).

If that’s acceptable, then that’s an even quicker way than what I proposed, but I didn’t get the impression that that would work for you, **Lionne**.

---

<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:** [October 18, 2007, 12:45am UTC](https://boards.straightdope.com/t/excel-query/422942/23 "2007-10-18T00:45:53Z")

</div>

True, but you could put in dummy rows: “26 - _INVALID_”

[Previous page](https://boards.straightdope.com/t/excel-query/422942.md?page=1)
