Forcing Cell formats, using round function?

mtb_rider

New Member
Joined
Feb 17, 2005
Messages
19
Hi

What I'm trying to do is on a summary page to express a calculated value in a "common sense" manner. So that if my criteria is that the value should be between 0.0999 and 1.0001 and my calculated value is 1.0000567 this gets rounded to 1.0001, likewise if my acceptable range is 49-51 and the calculated value is 50.114567 then the result will be rounded to 50.
There could be up to 7 sets of criteria and results all being transferred from calculation sheets via VBA. I actually want the rounded results not just the formatted to x decimals.

My design "idea" is that before transferring the data I will look at the number of decimal places that the range is expressed to and then round the answer prior to transfer.

Any ideas?

Thanks in advance
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

NBVC

Well-known Member
Joined
Aug 31, 2005
Messages
5,828
To get your result in the same number of decimal places, something like

=ROUND((B1-A1),LEN(MOD(A1,1))-2),

Where B1-A1 is an arithmetic argument yielding your desired result - before rounding occurs (could be any argument you wish),
A1 contains one of the numbers for the function to use to match number of decimal places to use.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,003
Messages
5,834,828
Members
430,324
Latest member
bosphoruskid

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
Top