Excel Formula for the Higher of Two Values: MAX or IF

Formulas & functions · Updated November 18, 2026

To return the higher of two values in Excel, use the MAX function. If the values are in cells A1 and B1, enter =MAX(A1,B1); Excel returns whichever value is larger.

The Basic MAX Formula

MAX is the simplest choice when you want the larger of two numbers, dates, or other comparable numeric values. Put the formula in a separate result cell so the source values remain unchanged. With the two values in A1 and B1, enter =MAX(A1,B1) in C1. If A1 contains 18 and B1 contains 25, C1 displays 25.

The commas separate the function’s arguments: in this case, the first cell and the second cell being compared. Excel does not require the cells to be next to each other. For example, a value in D4 can be compared with one in H4. With those values in D4 and H4, use =MAX(D4,H4) in the result cell.

You can also type numbers directly into the function, such as =MAX(18,25), but references are usually more useful. When a source value changes, a formula that refers to its cell recalculates automatically.

A Worked Example

Suppose a worksheet records the first and second bids for several items. Put the first bid in column B and the second bid in column C, with headings in row 1 and the first item in row 2. In D2, enter =MAX(B2,C2). If B2 is 145 and C2 is 162, D2 returns 162. If B2 is 210 and C2 is 194, D2 returns 210.

To apply the calculation to more items, select D2 and use the fill handle—the small square at the lower-right corner of the selected cell—to copy the formula down. Excel adjusts the row references as it fills: the next row compares B3 and C3, then the next compares B4 and C4. This is a relative reference, which is the normal behavior for cell references in a copied formula.

To enter the formula, select D2, type it in the cell or formula bar, and press Enter. On Windows, Ctrl+Enter can place the same entry in a selected range; on Mac, the equivalent is Control+Return. For a simple one-cell formula, pressing Enter is sufficient, and the same formula syntax works in Excel for Microsoft 365 on Windows, Mac, and the web.

MAX Versus IF

MAX is usually clearer than an IF formula for this task. An IF version tests which value is greater and then returns one of the cells. With the two values in A2 and B2, put =IF(A2>B2,A2,B2) in C2. If A2 is greater, C2 returns A2; otherwise, it returns B2.

There is an important tie detail: because the test uses the greater-than sign, equal values cause the formula to return B2. If you want a tie to return A2 instead, use a greater-than-or-equal comparison. With the same A2 and B2 layout, enter =IF(A2>=B2,A2,B2) in C2. For ordinary numeric comparisons, both approaches return the higher value; MAX avoids choosing a tie rule because the resulting number is the same either way.

Choose IF when the comparison needs a special outcome—for example, a message when the values match, or a different result when one cell is missing. For simply finding the larger number, MAX is shorter and easier to maintain.

Comparing More Than Two Values

Although the question often involves two cells, MAX can compare more than two values in one formula. With values in A2, B2, and C2, place =MAX(A2,B2,C2) in D2. If the cells contain 6, 11, and 9, the result is 11. Add another cell reference as another argument when you need to include another candidate.

For a continuous group of cells, use a range instead of listing each cell. With the candidate values in A2 through A10, enter =MAX(A2:A10) in B2. The colon means that the range includes every cell from A2 through A10. This is convenient when the list grows or when you want to compare a whole row or column segment. For example, if monthly figures are in B2:M2, use =MAX(B2:M2) in N2 to return the largest monthly figure.

Check that the range contains only the values you intend to compare. Including a total, an earlier result, or an unrelated numeric cell can change the answer without producing an obvious error.

Blanks, Text, and Errors

When MAX refers to cells, it ignores blank cells and text entries. With a number in A2 and B2 blank, =MAX(A2,B2) returns the number in A2. If both referenced cells are blank, the result is 0. A number stored as text is also ignored in a cell reference, so a cell that looks like 25 may not be treated like the numeric value 25 if it was imported or entered as text.

That behavior can matter when a blank is not meant to be ignored. For example, if one cell contains -5 and the other is blank, MAX returns -5 because the blank is ignored. If you intended a blank to count as zero, that is a different rule and should be stated explicitly in the worksheet’s logic rather than assumed.

Errors in referenced cells can also affect the result. If A2 contains an error such as #N/A, a calculation that compares A2 with B2 may return that error instead of a number. Find and correct the source error when possible. If you deliberately want an error to be replaced with a fallback, an error-handling function may be appropriate, but choose the fallback carefully: silently substituting zero can give a misleading “higher” value.

Be particularly cautious when substituting IF for MAX in a sheet with blanks or text. A comparison can treat an empty cell differently from the way MAX treats a blank argument. If the cells may be empty, decide whether an empty entry means zero, missing data, or a reason to leave the result blank, and build that rule into the calculation.

Dates, Times, and Percentages

Excel stores dates and times as numeric values, so MAX can return the later date or time. With dates in A2 and B2, enter =MAX(A2,B2) in C2. The result is the later date, provided both source cells contain real Excel dates rather than text that merely looks like a date. Format C2 as a date if Excel displays a serial number instead.

For times, with the two time entries in A2 and B2, =MAX(A2,B2) in C2 returns the later time of day. The result cell should have a time format. Formatting changes how the underlying value is displayed; it does not change which value the formula selected.

Percentages work the same way. With two rate values in A2 and B2, put =MAX(A2,B2) in C2 to return the larger rate. If A2 is 4.5% and B2 is 5%, the result is 5%. If the output appears as 0.05, apply Percentage formatting; the stored value is still the same. Avoid comparing values with different meanings or units, such as a percentage in one cell and a whole-number count in the other.

Choosing the Right Formula and Checking Results

For two numeric cells, choose MAX when you need only the higher value. Choose IF when the result depends on a condition beyond simply selecting the larger value. Before relying on either formula, check these practical points:

  • Confirm that both source cells contain numeric values, not numbers stored as text.
  • Decide how blanks should behave: ignored, treated as zero, or shown as missing.
  • Make sure the formula references the intended cells and that copied formulas point to the intended rows.
  • Check the result’s number format, especially for dates, times, percentages, and currency.
  • Test the formula with an example where the first value is larger and another where the second is larger.

For example, if A2 is 12 and B2 is 8, the formula in C2 should return 12; if you switch the inputs so A2 is 8 and B2 is 12, it should return 12 again. Testing both orders is a quick way to catch a reversed or mistyped comparison. A tie test can also confirm that an IF formula follows the tie behavior you chose.

Frequently Asked Questions

What is the Excel formula for the higher of two cells?

With the two values in A1 and B1, enter =MAX(A1,B1) in another cell. It returns the larger numeric value.

Can MAX compare two cells that are not next to each other?

Yes. With values in D4 and H4, enter =MAX(D4,H4) in the result cell. The referenced cells do not need to be adjacent.

How do I return the larger value from each row?

If each row has the two values in columns B and C and the first data row is row 2, enter =MAX(B2,C2) in D2, then fill the formula down. Excel adjusts the row references for each filled row.

Does MAX return the first value when the two values are equal?

MAX returns the shared numeric value, so there is no visible distinction between the first and second cell when they match. An IF formula can choose which cell to return on a tie, which matters if the cells contain additional distinctions beyond the displayed number.

Why does MAX return 0 when both cells are blank?

MAX ignores blank cells in referenced ranges and returns 0 when there are no numeric values to use. If a blank result is more appropriate for your worksheet, define that missing-data behavior separately instead of treating the default result as proof that the values were zero.

Can I use MAX to find the higher date or percentage?

Yes, as long as the cells contain real Excel date or percentage values. The function returns the larger stored value; apply a suitable date or percentage number format to display the result clearly.

Related

Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.

More in Formulas & functions

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.