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
 

Some videos you may like

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

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.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,455
Messages
5,572,235
Members
412,449
Latest member
mdvouf
Top