
Tips.Net > ExcelTips Home > Worksheet Functions > Math and Trig Functions > Establishing a FLOOR and CEILING
Summary: Two of the more esoteric rounding functions in Excel are FLOOR and CEILING. These functions allow you to round in very specific ways using multiples of numbers. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, and Excel 2003.)
Chances are good that you know how to use the primary rounding functions in Excel: ROUND, ROUNDUP, and ROUNDDOWN. There are two other similar functions you can use, as well: FLOOR and CEILING. The FLOOR function allows you to round down (toward zero) while the CEILING function rounds up (away from zero). Unlike other rounding functions, however, FLOOR and CEILING work with multiples of numbers. For instance, consider the following formula:
=FLOOR(27,12)
This formula will return a value of 24. Why? Because 24 is the largest multiple of 12 between 27 and 0. The CEILING function works similarly, as follows:
=CEILING(27,12)
This formula returns 36, since that is the next multiple of 12 away from zero, but larger than 27.
Both FLOOR and CEILING, as you can tell, require two arguments. The first is the number to be "rounded." Actually, this is a misnomer, as there is no real rounding taking place--the number represents the starting point for determining a relationship between the multiple value (the second argument) and zero.
FLOOR and CEILING can come in handy if you are trying to figure out multiples of items. (In this way it is similar to the MROUND function.) For instance, suppose you were running your youth group candy sale, and you could only deliver candy to the kids in full boxes. Each box contained 12 candy bars. Suppose cell B3 contained an order quantity, and cell C3 contained the number of candy bars in each box (in this case, 12). You could place the following formula in cell D3 to return the number of full boxes that should be delivered:
=FLOOR(B3,C3)/C3
If the number of candy bars ordered (in cell B3) is 31, then the value returned by the formula will be 2. (2 boxes at 12 bars each is 24 bars.) Granted, this formula could also be easily constructed using the INT or TRUNC functions (Excel very often provides multiple ways to accomplish the same tasks). You could use the CEILING function in place of the FLOOR function in this example if you wanted to "round up" to the next full box above what is required for the candy order:
=CEILING(B3,C3)/C3
Using the same scenario, this formula would return 3 (3 boxes, or 36 candy bars).
When using FLOOR and CEILING, remember that the sign of the arguments must match. If one argument is positive and the other negative, Excel returns an error value of #NUM!.
Tip #2152 applies to Microsoft Excel versions: 97 2000 2002 2003
More Power! For some people, the prospect of creating macros can be scary. Those who conquer their fears, however, find they become much more confident and productive once they learn how to make Excel do exactly what they want. ExcelTips: The Macros is an invaluable source for learning Excel macros. You are introduced to the topic in bite-sized chunks, pulled from past issues of ExcelTips. Learn at your own pace, exactly the way you want.
Check out ExcelTips: The Macros today!
PivotTables don't need to be scary or mysterious. Use this powerful tool to analyze your data in ways you didn't know were possible. (more information...)
Ask an Excel Question
Make a Comment
ExcelTips FAQ
ExcelTips Premium
Bugs and Pests Tips
ExcelTips
Family Tips
Health Tips
Home Tips
Organizing Tips
WordTips
Advertise on the
ExcelTips Site