Rounding to a specific value based on range

TC_Mike

New Member
Joined
May 5, 2008
Messages
18
I’ve been using the following formula to calculate margin and do the rounding to the closest .x9
=ROUND(($A1/0.7),1)-0.01

Now there are certain price points that I want to hit (or avoid) so I’m trying to create a formula to only hit these price points. The formula would do the following,

Retails ending in …
x.00 to x.10 would round down to .99
x.11 to x.30 would round to x.29
x.31 to x.50 would round to x.49
x.51 to x.80 would round to x.79
x.81 to x.99 would round to x.99


If I have to calculate the margin separately, that would be OK, but I was trying to get it all done in one cell.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hi TC_Mike,

Try using below formula;-

=IF(MOD(A1,1)=0,INT(A1)-0.1,LOOKUP(IF(ISNUMBER(SEARCH(".",RIGHT(A1,2))),(RIGHT(A1,1)&0)*1,(RIGHT(A1,2)*1)),{11,31,51,81},{29,49,79,99}))


Regards,
DILIPandey
 
Upvote 0
See if this does what you want.

Excel Workbook
AB
1NumberRounded
23.052.99
312.1812.29
40.50.49
57.517.79
67.937.99
Rounding
 
Upvote 0
Thanks to DILIPandey & Peter_SSs for chiming in. Peter_SSs's formula worked best for me. Here are the side by side results of the two.

rounding.jpg
 
Upvote 0
Thanks for the heads- up Mike. This happens when one does'nt do a proper testing :)

Revising the formula as :-

=IF(OR(MOD(A1,1)=0,RIGHT(A1,3)*1<=0.1),((INT(A1)-1)&"."&99)*1,(INT(A1)&"."&LOOKUP(IF(ISNUMBER(SEARCH(".",RIGHT(A1,2))),(RIGHT(A1,1)&0)*1,(RIGHT(A1,2)*1)),{1,11,31,51,81},{99,29,49,79,99}))*1)

Which is giving correct results as per above data sample.


Regards,
DILIPandey
 
Upvote 0

Forum statistics

Threads
1,215,261
Messages
6,123,930
Members
449,134
Latest member
NickWBA

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