To return the larger of two numbers in Excel, use the MAX function. With the values in A1 and B1, enter =MAX(A1,B1); if A1 contains 12 and B1 contains 19, the result is 19. This is the simplest choice when you need the greater numeric value, regardless of which cell contains it.
The simplest formula
Put the two numbers in separate cells, then enter the formula in a third cell. For example, with the first number in A1 and the second in B1, type =MAX(A1,B1) in C1 and press Enter. Excel compares the two values and displays the larger one. The formula returns a number, not a sentence explaining which input won.
You can also type the values directly into the function, but cell references are usually more useful because you can change the inputs without rewriting the formula. For instance, if A1 changes from 12 to 25, the result in C1 recalculates automatically. In Microsoft 365 for Windows, you can select C1, type the formula in the formula bar or directly in the cell, and press Enter. The same formula works in current Excel for Mac and Excel for the web.
MAX is a built-in Excel function, so it does not require an add-in or a special setting. It is also available in older Excel versions, making it a good option when a workbook may be opened by people using different editions.
What MAX does
MAX returns the greatest numeric value from the numbers you supply. Its arguments can be individual cell references, typed numbers, or ranges. With two cell references, it is a direct answer to “which number is larger?” With a longer list, the same function finds the greatest value in the entire set.
For example, with weekly measurements in B2 through B8, enter =MAX(B2:B8) in C2 to return the highest measurement in that range. If the values are 4, 9, 6, 11, 7, 3, and 8, the result is 11. The colon in the reference indicates the inclusive range from B2 to B8.
The function returns the value itself. If A1 and B1 both contain 19, the result is 19; MAX does not tell you whether the value came from A1, B1, or both. If you need a label, location, or explanation alongside the result, you need an additional formula or a different approach.
When an IF formula is useful
Use MAX for the larger value in ordinary numeric comparisons. Choose IF when your logic needs to distinguish the two inputs—for example, when you want to return a particular cell’s value according to a comparison, or when you want to decide what happens in a tie.
With A1 and B1 holding the two numbers, enter =IF(A1>B1,A1,B1) in C1 to return A1 when it is greater and B1 otherwise. If A1 is 12 and B1 is 19, the result is 19. If they are equal, this version returns B1, even though both cells contain the larger value. That tie behavior follows from the test: A1 is not greater than B1 when the values are equal.
If you prefer the first cell to win ties, use a greater-than-or-equal comparison. With the same layout—numbers in A1 and B1, result in C1—enter =IF(A1>=B1,A1,B1). When A1 and B1 are both 19, this formula returns A1’s value. For a simple numeric maximum, however, MAX is shorter and makes the intent clearer.
Worked examples
These examples show how the choice of formula depends on the data and the output you want:
- Two positive numbers: With 42 in A1 and 37 in B1, enter
=MAX(A1,B1)in C1. The result is 42. - Two negative numbers: With -8 in A2 and -3 in B2, enter
=MAX(A2,B2)in C2. The result is -3, because -3 is greater than -8. “Larger” means greater on the number line; it does not mean the number with the greater absolute size. - A changing comparison down a list: With one pair of values in A2 and B2 and further pairs in the rows below, enter
=MAX(A2,B2)in C2. Copy the formula down to compare each row’s pair. Excel adjusts the relative row references as the formula is copied. - A list of several values: With values in D2 through D12, enter
=MAX(D2:D12)in D13 to return the largest value in the list. This avoids writing each reference separately.
For the row-by-row example, keep the result column separate from the input columns so that the formula does not overwrite a value it needs to compare. If you copy a formula across or down, check that the references move as intended. Absolute references, which use dollar signs such as $A$1, stay fixed when copied; ordinary references such as A1 adjust relative to the new location.
Blanks, text, and errors
Data quality can affect what a maximum calculation means. When MAX refers to cells, it ignores empty cells and text entries. If A1 contains 15 and B1 is empty, =MAX(A1,B1) returns 15. If both referenced cells are empty or contain only text, MAX returns 0. That zero is a function result, not proof that a zero was present in the source data.
A number stored as text can also be overlooked when it is in a referenced cell. For example, a cell may display 25 but contain text rather than a numeric 25. If A1 is a true number 15 and B1 contains text that looks like 25, =MAX(A1,B1) may return 15 because the text entry is not treated as a number in the referenced range. Check the cell’s contents and formatting, and convert text-formatted numbers to real numbers when appropriate.
Errors are different: if one of the referenced cells contains an error such as #N/A or #VALUE!, the maximum calculation can return that error rather than a numeric answer. Fix the source error or decide explicitly how the calculation should handle it; hiding an error without understanding it can make a result misleading. Similarly, if a formula in an input cell returns an empty string, that is text rather than a truly empty cell, so consider how the rest of the data is structured.
These behaviors matter most in imported data, reports with optional entries, and sheets where formulas produce blanks. Before trusting a result, confirm that both inputs are numeric values and that missing values should genuinely be ignored.
Choosing the right approach
For two numbers, MAX is usually the clearest formula. It expresses the goal directly and extends naturally to more than two values. Use IF if the comparison should trigger different outcomes, or if you need to control which input is selected in a tie. Neither function is inherently more accurate; the right choice depends on whether you want a maximum value or conditional logic.
Ask what the result needs to communicate:
- If you need only the greatest numeric value, use
MAX. - If you need a specific value or response depending on which side wins, use
IFwith a comparison that matches your tie rule. - If you need to identify the source cell or its associated label, a maximum value alone is not enough; add a lookup or selection step appropriate to your worksheet.
- If the inputs may be blank, text, or errors, decide how those cases should be treated before choosing the final formula.
This distinction prevents a common misunderstanding: a formula that returns the larger number does not automatically identify the winning row, person, product, or category. The number and its associated label are separate pieces of information.
Common mistakes to avoid
One frequent mistake is comparing the wrong cells. Before entering a formula, confirm where the two inputs are and where the result should go. If the result cell is one of the input cells, the formula may overwrite data or create a circular reference. Put the result in a separate cell.
Another is using a comparison that reverses the desired outcome. In an IF formula, the condition comes first, followed by the value returned when it is true and then the value returned when it is false. Read the formula in that order and test it with an example where the first number is larger, then another where the second is larger. Test a tie too if ties matter.
Do not confuse “larger” with “farther from zero.” For -8 and -3, the larger number is -3, although -8 has the greater absolute magnitude. If the goal is to compare magnitudes, that is a different calculation and should be stated explicitly.
Finally, remember that displayed formatting can hide differences. Two cells might both display 10 while storing values such as 10.2 and 10.4 because they are formatted with no decimal places. MAX compares the underlying values, so it returns 10.4 even though both inputs may appear as 10. Increase the displayed decimal places or inspect the formula bar if the result seems surprising.
Frequently Asked Questions
What Excel formula returns the larger of two numbers?
Use =MAX(A1,B1) when the numbers are in A1 and B1. Replace those references with the cells containing your values. The function returns the greater numeric value.
Does MAX work with negative numbers?
Yes. It compares negative numbers by their numerical value. For -8 and -3, MAX returns -3, because -3 is greater on the number line.
What happens if both numbers are equal?
MAX returns their shared value. It does not indicate that the inputs tied or specify which cell supplied the result.
How do I return the larger value and choose the first cell in a tie?
With values in A1 and B1 and the result in C1, use =IF(A1>=B1,A1,B1). The greater-than-or-equal test returns A1 when the numbers are equal.
Can I use MAX to find the largest number in a range?
Yes. For values in B2 through B20, enter =MAX(B2:B20) in a separate cell. It returns the largest numeric value in that range, while ignoring blank cells and text entries.
Related
- Conditional Formatting in Microsoft Project: What Works
- Data Validation and Verification in Excel Explained
- Power Query Replace Text: Steps, Options, and Examples
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Excel DATEDIF Age Formula: Calculate Years, Months & DaysTo calculate someone’s age in completed years in Excel, enter their birth date in A2 and use =DATEDIF(A2,TODAY(),"Y").…
- Excel Minutes Between Two Times: Formula and ExamplesIf the start time is in A2 and the end time is in B2, enter =(B2-A2)*1440 to calculate…
- RANK Excel Function: Examples, Ties, and Sort OrderTo rank a value in Excel, use RANK.EQ(number,ref,[order]): for example, with scores in B2:B6, =RANK.EQ(B2,$B$2:$B$6,0) returns B2’s position…
- Excel OFFSET Height: How the Argument Works in FormulasIn Excel, OFFSET’s height argument sets how many rows the returned reference includes; it does not control how…
- Excel Filter Shortcut: Add, Remove, and Use FiltersIn Excel for Microsoft 365 on Windows, press Ctrl+Shift+L to add filter dropdowns to a selected data range—or…
- Excel FLOOR Formula for Time: Round Down by MinutesTo round an Excel time down to the nearest 15 minutes, use =FLOOR.MATH(A2,TIME(0,15,0)), assuming the time is in…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.