How to Round Numbers

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,616
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
In my code, I run into values of a variable (tdur) representing duration (in hours) .

These are some examples:

0.53
1.53
2.11
1.06
1.32
2.64
0.26

I would like to round these to the nearest 30 minutes. So, with these example:

0.5
1.5
2.0
1.0
1.5
3.0
0.5

I thought it was more simple than it is.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
in the real excel anything over 1 is a day, so you will need to use 24 to get it into a position that it will look like hours, giving you always less than 1, then you could add CEILING. Are you always rounding up or down or allow it to work to natural limits
 
Upvote 0
[table="width:, class:grid"][tr][td="bgcolor:#c0c0c0"][/td][td="bgcolor:#c0c0c0"]
a​
[/td][td="bgcolor:#c0c0c0"]
b​
[/td][td="bgcolor:#c0c0c0"]
c​
[/td][/tr][tr][td="bgcolor:#c0c0c0"]
2​
[/td][td]
0.53​
[/td][td="bgcolor:#ccffcc"]
0.5​
[/td][td="bgcolor:#ccffcc"]b2: =mround(a2, 0.5)[/td][/tr]
[tr][td="bgcolor:#c0c0c0"]
3​
[/td][td]
1.53​
[/td][td="bgcolor:#ccffcc"]
1.5​
[/td][td][/td][/tr]
[tr][td="bgcolor:#c0c0c0"]
4​
[/td][td]
2.11​
[/td][td="bgcolor:#ccffcc"]
2.0​
[/td][td][/td][/tr]
[tr][td="bgcolor:#c0c0c0"]
5​
[/td][td]
1.06​
[/td][td="bgcolor:#ccffcc"]
1.0​
[/td][td][/td][/tr]
[tr][td="bgcolor:#c0c0c0"]
6​
[/td][td]
1.32​
[/td][td="bgcolor:#ccffcc"]
1.5​
[/td][td][/td][/tr]
[tr][td="bgcolor:#c0c0c0"]
7​
[/td][td]
2.64​
[/td][td="bgcolor:#ccffcc"]
2.5​
[/td][td][/td][/tr]
[tr][td="bgcolor:#c0c0c0"]
8​
[/td][td]
0.26​
[/td][td="bgcolor:#ccffcc"]
0.5​
[/td][td][/td][/tr]
[/table]
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top