Sub topic 5
Finding the smallest and largest values with MIN and MAX
This chapter assumes you can enter values in cells, select ranges, and start a formula with an equals sign. It also assumes you have seen the function pattern from SUM: a name, parentheses, and arguments separated by commas.
What MIN and MAX return
MIN returns the smallest number in its arguments. MAX returns the largest. Both take the same kinds of arguments as SUM: single cells, ranges, constants, or a mix.
Suppose B2:B6 holds monthly sales figures.
| Cell | Value |
|---|---|
| B2 | 120 |
| B3 | 85 |
| B4 | (blank) |
| B5 | 240 |
| B6 | n/a |
=MIN(B2:B6)
=MAX(B2:B6)
=MAX(B2:B6)-MIN(B2:B6)These return 85, 240, and 155. The third formula gives the spread (also called the range) between the extremes. The blank in B4 and the text in B6 are skipped.
How the functions read a range
When an argument is a range or a cell reference, MIN and MAX consider only numeric cells. They ignore blanks, text, and logical values (TRUE and FALSE) stored in cells.
Values typed directly into the formula follow different rules. A logical such as TRUE counts as 1, and text that looks like a number, such as "5", is converted. Text that cannot be converted returns #VALUE!.
=MAX(3, TRUE, "5")This returns 5. Typed constants are rare in real worksheets, so this mostly matters when you copy a formula from an example.
Several arguments at once
You can compare across separate ranges and constants in one call.
=MAX(B2:B6, D2:D6, 500)This returns the largest value among both ranges and the number 500. A common use is a floor or cap. =MAX(B2, 0) never returns less than 0, and =MIN(B2, 100) never returns more than 100.
Common errors
Two behaviors surprise people.
- No numbers means 0. If the range has no numeric cells, both functions return 0, not an error. A column of empty cells or one holding only text gives
MINandMAXresults of 0, which looks like real data. - Errors pass through. If any cell in the range holds an error such as
#N/A, the whole formula returns that error.
Numbers stored as text are a third cause of wrong answers. A cell showing 300 but left-aligned and stored as text is skipped, so MAX may report a smaller number than you can see. Convert such cells to real numbers before relying on the result.
A guard for the empty case uses COUNT, which counts numeric cells:
=IF(COUNT(B2:B6)=0, "No data", MIN(B2:B6))Hidden and filtered rows
MIN and MAX include hidden and filtered-out rows. To ignore them, use SUBTOTAL with function number 105 for minimum or 104 for maximum.
=SUBTOTAL(105, B2:B6)
=SUBTOTAL(104, B2:B6)A later chapter covers SUBTOTAL in more detail.
Exercise
A1:A4 contains 10, the text "twelve", an empty cell, and 7. What do =MIN(A1:A4) and =MAX(A1:A4) return, and what would they return if A1:A4 had only text and blanks?
Show answer
MIN returns 7 and MAX returns 10, because the text and the blank are skipped. If the range had only text and blanks, both would return 0, since there are no numbers to compare.