# Dividing to find an integer

#### ddocg

##### Board Regular
Hi,

Is there a formula that would return an integer from a division calculation?

For example:

A1 will contain a varying non integer

In A2 I would like to show the integer from dividing the value in A1 however, this division is limited by a set number.

If A1 = 2.962 this number should then be divided by, at most, 0.220 this would return 13.463 which is no use, I need it to return a whole number so, the formula would need to iterate down from 0.220 until it returns an integer in this case 14 for 0.211 or ideally return 16 for 0.185

I don't know if what I'm asking is even possible in excel, hopefully it is, I appreciate it may need more cells than A1 and A2 which fine.

### Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

#### Eric W

##### MrExcel MVP
2.962 divided by .211 is 14.03791. 2.962 divided by .185 is 16.01081. Neither one is an integer. Are you looking for some specific tolerance? Say, the decimal must be less than .02? Or do you want to try all values from .220 to .001 decreasing by .001 at a time, and return the value that results in the smallest decimal?

#### Joe4

Why is 16 ideal over 14?

You said that the divisor cannot be more than 0.220, but that leaves a lot of options open.
So, we need to know what is considered to be "ideal", what we are striving for.

#### ddocg

##### Board Regular
Apologies Eric, I should have been more specific, I also note I have changed the order of the calculation below, again, I should have been more specific.

The value in A1 is a distance in metres, in this case 2 metres 962 millimetres, working to 3 decimal places, if I divide 2.962 by 14 I get 0.212 - not 0.211 as I incorrectly stated above - which is great because it is less than 0.220

Dividing by 13 it would be 0.228 which is no use as it is greater than 0.220

I am trying to work out how many treads are required in a flight of stairs, the 2.962 is the distance from finished floor to finished floor and each tread height has to be <= to 220mm - it may well be that I would want 16 treads which would be more comfortable at 0.185

I'm now thinking a list with a Vlookup might be a better way as it would allow selection of the preferred rise.

#### shg

##### MrExcel MVP
 A​ B​ C​ D​ E​ 1​ Delta H​ Steps​ Rise/Step​ ​ ​ 2​ 2.962​ 14​ 0.212​ B2: =CEILING(A2 / 0.22, 1) 3​ 2.745​ 13​ 0.211​ C2: =A2/B2 4​ 2.781​ 13​ 0.214​ 5​ 3.335​ 16​ 0.208​ 6​ 2.846​ 13​ 0.219​

Note that there is actually one less, because the last step is the the finished floor.

Last edited:

#### Eric W

##### MrExcel MVP
It seems that for stairs, you would also have a minimum rise. A rise of .002 would give you an exact integer, but you'd end up with 1481 stairs! So you'd only need to divide 2.962 from the minimum height to the maximum height to get a range of acceptable stair counts. But it also seems you need to worry about the width of the stair. For a given width of the entire stairwell, the more stairs you have, the narrower each stair would be. I'm not a builder, so I really can't say. It might be best to figure out the numbers once, then put the results in a VLOOKUP table. I've also seen cases where the bottom or top stair is slightly shorter than the rest. I'm sure there are rules governing that, but I don't know them.

#### ddocg

##### Board Regular
It seems that for stairs, you would also have a minimum rise. A rise of .002 would give you an exact integer, but you'd end up with 1481 stairs! So you'd only need to divide 2.962 from the minimum height to the maximum height to get a range of acceptable stair counts. But it also seems you need to worry about the width of the stair. For a given width of the entire stairwell, the more stairs you have, the narrower each stair would be. I'm not a builder, so I really can't say. It might be best to figure out the numbers once, then put the results in a VLOOKUP table. I've also seen cases where the bottom or top stair is slightly shorter than the rest. I'm sure there are rules governing that, but I don't know them.
Thank you Eric,

I have it working now using Vlookup - the width is not an issue as the calculator is only for a single flight, so far! though, I think, when you reference width you actually mean the length of the stair which here is referenced as the total going, my calculator does take this into account as it has to satisfy a maximum angle of 42 degrees

There are regulations that govern a stair construction and your example of a stair that has a smaller step at either the top or bottom is likely a result of incorrect dimensions being conveyed at the time of order hence, the stair was adapted to fit........ happens a lot!

#### ddocg

##### Board Regular
 A​ B​ C​ D​ E​ 1​ Delta H​ Steps​ Rise/Step​ 2​ 2.962​ 14​ 0.212​ B2: =CEILING(A2 / 0.22, 1) 3​ 2.745​ 13​ 0.211​ C2: =A2/B2 4​ 2.781​ 13​ 0.214​ 5​ 3.335​ 16​ 0.208​ 6​ 2.846​ 13​ 0.219​

<tbody>
</tbody>

Note that there is actually one less, because the last step is the the finished floor.
Thank you SHG,

I'll look into the Ceiling command and see if I can find a use for it, I do appreciate you taking the time to reply, very helpful.

#### Giordano Bruno

##### Well-known Member
Hi ddocg,

Why is it so complicated? Surely all you need do is decide your minimum riser height, say 170mm and divide the floor height difference by that and round the number down. That will give you the number of risers which will be the same whether you have a landing or not. If you need the number of treads, it's number of risers minus number of landings - 1 If you want a count of treads, perhaps to count the number of nosing tiles or something it's equal to the number of risers. There is never a need to have each riser as a millimetre integer.