# HLOOKUP

## Content

This function searches for a value in the top row and then returns a value in the same column from a specified row.

## Syntax

`HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])`

## Arguments

This function has these arguments:

| **Argument** | **Description** |
| -------- | ----------- |
| *lookup\_value* | The value to search for in the first row of *table\_array*. The value can be a value or a cell reference. |
| *table\_array* | The cell range that contains the lookup data. The first row of the range contains the values to search. |
| *row\_index\_num* | The row number in *table\_array* from which to return a value. The first row of *table\_array* is row 1. |
| *range\_lookup* | [Optional] A Boolean value that specifies the matching method. Specify `FALSE` for an exact match or `TRUE` for an approximate match. The default value is `TRUE`. |

## Remarks

* If *range\_lookup* is `TRUE` or omitted, the values in the first row of *table\_array* should be sorted in ascending order. If an exact match is not found, the function returns the largest value that is less than or equal to *lookup\_value*.
* If *range\_lookup* is `FALSE`, the values in the first row do not need to be sorted. If no exact match is found, the function returns the `#N/A` error.
* When *range\_lookup* is `FALSE` and *lookup\_value* is text, you can use the question mark (`?`) and asterisk (`*`) wildcard characters. To search for an actual question mark or asterisk, type a tilde (`~`) before the character.
* Text comparisons are not case-sensitive.
* If *row\_index\_num* is less than 1, the function returns the `#VALUE!` error.
* If *row\_index\_num* is greater than the number of rows in *table\_array*, the function returns the `#REF!` error.

## Data Types

Accepts numeric data, string data, Boolean data, and cell references.
Returns numeric data, string data, Boolean data, or an error value.

## Examples

```auto
activeSheet.setFormula(1, 8, '=HLOOKUP("Current",A1:G33,3,FALSE)');
activeSheet.setFormula(3, 8, '=HLOOKUP(B6,A1:F4,4,TRUE)');
```