Per your private message, the logic can be broken into two parts:
Time:
Excel stores time as fraction of a day, where 1 = 24 hours. So by subtracting time, excel storing this as a fraction. for example subtracting 18:00 and 6:00 with has excel storing .5 as a value if you change format to general. by multiplying this by 24, it will reflect the inter 12. Change 18 to 18:30 this changes what excels stores to approximately .52, which shows as 12.5 hours when mutliplied by 24.
The time portion of the formula is all in this part of the formula
(B1-A1)*24
Rounding:
This works for all numbers. Lets just say you wanted to round a number, 7, to the nearest 5. The forlmula would be
=ROUND(7/5,0)*5
excel just caluates 7/5 which is 1.4, rounds it the nearest whold number (1) and that multiplies it back by 5 - for a result of 5.
Change the number to 7.5 and the divsions result is 1.5, which rounds to 2 for a result of 10.