Skip to main content

Kutools for Office — One Suite. Five Tools. Get More Done.

How to quickly find the largest value but smaller than X in Excel?

Author Sun Last modified

In everyday Excel tasks, identifying the largest value within a dataset is straightforward using simple functions. However, when your requirement is to find the largest value that is still smaller than a specific threshold—such as “the largest value less than 100”—the challenge grows, especially when dealing with large data ranges or dynamic conditions. This scenario frequently arises when setting data limits, analyzing performance relative to a minimum threshold, or filtering values for reporting purposes. Fortunately, Excel offers multiple approaches to tackle this need efficiently and reliably. This guide will walk you through practical methods to quickly locate the largest value less than a specified number, along with applicable scenarios, tips, and troubleshooting advice.

a screenshot showing the original data and the condition

Find largest value less than X with formulas

Find largest value less than X with Kutools for Excel

Find largest value less than X using VBA code


Find largest value less than X with formulas

Excel formulas allow you to quickly determine the largest value below a certain number, such as 100, within a specified range (for example, A1:E7). This solution is ideal for static data sets or for users who prefer working directly with worksheet functions. It is accurate and does not require any add-ins or advanced skills.

1. Click a blank cell where you want to display the result, and enter the following formula. For this example, we will search for the largest value less than 100 in the range A1:E7:

=MAX(IF(A1:E7<100,A1:E7,""))

Tip: This is an array formula. In Excel versions earlier than Office 365, you must press Ctrl + Shift + Enter to activate it, and curly braces {} will appear around the formula. In newer Excel (Office 365 and later), simply press Enter.

 
a screenshot of an arrow
a screenshot of the final result

If no values fall below the specified threshold (e.g., if all data in the range is greater than or equal to 100), the result returned is zero. In such cases, consider using the following formula to return "No match":

=IF(SUMPRODUCT(--(A1:E7<100))=0, "No match", MAX(IF(A1:E7<100,A1:E7)))

After entering this formula in the target cell, press Ctrl + Shift + Enter to return the largest number less than 100. To apply this to other ranges, simply adjust the cell references within the formula.

Pros: Quick and flexible for one-time lookups or simple conditions.
Cons: May require formula adjustment for changing criteria or dynamic ranges. Array formulas can be less intuitive for beginners.

Practical tips: Use cell references or named ranges in place of hardcoded values to enhance flexibility. For example, replace 100 with a cell reference (e.g., $G$1) to dynamically change the threshold.

Troubleshooting: If you receive a #VALUE! error, check that your range contains only numbers and that the threshold is specified correctly. For large ranges, array formulas may slow down workbook performance.


Find largest value less than X with Kutools for Excel

Kutools for Excel provides enhanced formula tools to streamline your workflow, especially when standard formulas become too complex or difficult to recall. Its built-in Formula Helper feature lets you set up find-criteria-based lookups with simple mouse actions, avoiding manual formula entry and reducing the risk of error. This is especially practical for users who frequently need to adjust parameters or process large tables efficiently.

After free installing Kutools for Excel, please follow these steps:

1. Click the cell where the found value will be shown, then go to Kutools > Formula Helper > Formula Helper.

2. Within the Formulas Helper dialog:

1) Select Lookup from the Formula Type drop-down menu;
2) In Choose a formula, select Find the largest value less than;
3) For Range, specify your data range. In Max value, input the threshold number.
a screenshot of configuring the corresponding formula

3. Click OK. Kutools instantly returns the largest value less than your specified number.
a screenshot showing the final result

This approach does not require special formula knowledge and supports flexible parameter adjustment. For repeated analyses, Kutools saves significant time over manual entry.

Pros: Suitable for frequent or complex queries; prevents formula mistakes; convenient for non-technical users.
Cons: Requires Kutools installation; not available in a default Excel environment.

Precaution: Double check selected ranges and input values to avoid logic errors. If the data contains blanks or non-numeric cells, review the output for accuracy.

Practical tip: Named ranges can make selection easier in Kutools dialogs, especially with large tables.

Troubleshooting: If no result appears, review your input criteria, ensure Kutools is properly installed, and confirm that your data range contains numeric values below the threshold.


Find largest value less than X using VBA code

Excel VBA (Visual Basic for Applications) can be leveraged to automatically loop through a range and find the largest value less than a specified threshold. VBA is suitable for situations where:

  • You need to handle dynamic ranges that may change in size
  • You want to automate the searching process without complex array formulas
  • You must repeatedly perform this analysis or embed the solution into a workflow

This method is especially practical for power users or those dealing with regularly updated datasets. The following steps explain how to set up and execute the VBA solution.

1. In Excel, go to the Developer Tools tab, click Visual Basic to open the Microsoft Visual Basic for Applications editor. Click Insert > Module, and paste the code below into the new module:

Sub FindLargestLessThanX()
    Dim WorkRng As Range
    Dim xCell As Range
    Dim xMax As Double
    Dim xThreshold As Double
    Dim xTitleId As String
    
    On Error Resume Next
    xTitleId = "KutoolsforExcel"
    
    Set WorkRng = Application.Selection
    Set WorkRng = Application.InputBox("Select range to search", xTitleId, WorkRng.Address, Type:=8)
    
    xThreshold = Application.InputBox("Enter the threshold value", xTitleId, "", Type:=1)
    
    xMax = -1E+308 ' Initialize to very small number
    
    For Each xCell In WorkRng
        If IsNumeric(xCell.Value) Then
            If xCell.Value < xThreshold And xCell.Value > xMax Then
                xMax = xCell.Value
            End If
        End If
    Next
    
    If xMax = -1E+308 Then
        MsgBox "No value found less than " & xThreshold, vbInformation
    Else
        MsgBox "Largest value less than " & xThreshold & " is: " & xMax, vbInformation
    End If
End Sub

2. To run the code, click the Run button button, or press F5. A dialog will appear prompting you to select a data range, then enter the threshold value (for example, 100). The result will display as a message box.

Pros: Ideal for automation and dynamic tables; handles changing ranges without manual adjustment.
Cons: Requires enabling macros; some users may not be familiar with VBA setup.

Precaution: Ensure macros are enabled in your Excel environment. Only run VBA code in trusted workbooks.
Tip: You can modify the VBA script to write the output value to a specified worksheet cell instead of a dialog box for further processing.

Troubleshooting: If the code does not execute, verify that macros are allowed, inputs are entered in correct format, and your selection contains numeric values.

This VBA approach makes it easy to perform the task on dynamically updated data, automate repetitive operations, or avoid limitations of formulas on very large ranges.


Relative Articles:


Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!

All Kutools add-ins. One installer

Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.

Excel Word Outlook Tabs PowerPoint
  • All-in-one suite — Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
  • One installer, one license — set up in minutes (MSI-ready)
  • Works better together — streamlined productivity across Office apps
  • 30-day full-featured trial — no registration, no credit card
  • Best value — save vs buying individual add-in