This post will guide you how to** find the first value greater than a specified value in a range of cells** in Excel. How do I find the last value greater that a given value in a row with a formula in Excel.

Assuming that you have a list of data in range B1:B6, in which contain numeric values. And you want to find the first number from the list that is greater than a given number (30). Or you wish to find the last one number from your data that is greater than a number 30. The below will show you one formula to accomplish it.

Table of Contents

## 1. Find the Last Value Greater Than X Using Formula

If you want to identify the last value in your range **B1:B6** that is greater that number **30**, you can use the following array formula based on the LOOKUP function and the IF function. Like this:

`=LOOKUP(9.999999999E+307,IF(B1:B6>30,B1:B6))`

You can type the above formula into a blank cell in your worksheet, and make sure to press **Ctrl +shift +Enter** keys on your keyboard to change your formula as array formula.

## 2. Find the Last Value Greater Than X with VBA Code

You can also use a **user-defined function **(vba code) to find the last value greater than a given value in Excel. You just need to do the following steps:

**Step1:** Open your Excel workbook and press **Alt + F11** to open the Visual Basic Editor.

**Step2:** In the editor, click on “**Insert**” and select “**Module**” from the drop-down menu.

**Step3:** In the new module, enter the following code, and save the module and return to the Excel worksheet.

Function LastGreaterThanbyExcelhow(R As Range, Val As Variant) As Variant Dim i As Integer LastGreaterThanbyExcelhow = "" For i = R.Cells.Count To 1 Step -1 If R.Cells(i).Value > Val Then LastGreaterThanbyExcelhow = R.Cells(i).Value Exit Function End If Next i End Function

**Step4:** In a blank cell, enter the formula:

`=LastGreaterThanbyExcelhow(A1:A6, 30)`

Where **A1:A6** is the range of cells you want to search for the last value greater than the given value and “**30**” is the given value.

**Step5:** Press **Enter **to calculate the function and display the result.

**Note:**The function will return an empty string (“”) if no value is found greater than the given value.

## 3. Find the First Value Greater Than X Using Formula

If you want to find the first value in a range that is greater that number 30, you can use the following formula based on the INDEX function and the MATCH function to identify the first value in the range B1:B6 greater that number 30. Like this:

`=INDEX(B1:B6,MATCH(TRUE,INDEX(B1:B6>30,0),))`

You just need to type the above formula into a blank cell in your worksheet, and make sure to press **Ctrl +shift +Enter **keys on your keyboard to change your formula as array formula.

## 4. Find the First Value Greater Than X with VBA Code

You can also use a user-defined function in Excel to find the first value greater than a given value in a range of cells. Here is the VBA Code:

Function FindFirstGreaterThanExcelhow(TargetValue As Double, RangeToSearch As Range) As Double Dim cell As Range For Each cell In RangeToSearch If cell.Value > TargetValue Then FindFirstGreaterThanExcelhow = cell.Value Exit Function End If Next cell FindFirstGreaterThanExcelhow = CVErr(xlErrValue) End Function

In a cell, enter the formula:

` =FindFirstGreaterThanExcelhow(30, A1:A6)`

Where **30 **is the value you want to search for and **A1:A6** is the range of cells to search.

Press **Enter** to execute the formula and the function will return the first value greater than the target value in the specified range.

## 5. Video: Find the Last or First Value in a Range Greater Than X in Excel

This video will demonstrate how to find the last or first value in a range greater than X in Excel using a formula or a User Defined Function (UDF).

## 6. Related Functions

- Excel LOOKUP function
The Excel LOOKUP function will search a value in a vector or array.The syntax of the LOOKUP function is as below:= LOOKUP (lookup_value, lookup_vector, [result_vector])…
- Excel IF function

The Excel IF function perform a logical test to return one value if the condition is TRUE and return another value if the condition is FALSE. The IF function is a build-in function in Microsoft Excel and it is categorized as a Logical Function.The syntax of the IF function is as below:= IF (condition, [true_value], [false_value])…. - Excel INDEX function

The Excel INDEX function returns a value from a table based on the index (row number and column number)The INDEX function is a build-in function in Microsoft Excel and it is categorized as a Lookup and Reference Function.The syntax of the INDEX function is as below:= INDEX (array, row_num,[column_num])… - Excel MATCH function

The Excel MATCH function search a value in an array and returns the position of that item.The MATCH function is a build-in function in Microsoft Excel and it is categorized as a Lookup and Reference Function.The syntax of the MATCH function is as below:= MATCH (lookup_value, lookup_array, [match_type])….