Nearest whole number to divide by to be near a value

Caly

Board Regular
Joined
Jul 19, 2015
Messages
160
Office Version
  1. 365
  2. 2013
  3. 2011
  4. 2010
  5. 2007
Platform
  1. Windows
Hello I have a range of numbers and need to make a formula where that larger number can easily be divisible by a whole number in order to then have the price be near $20. It can be above or below but as close as possible to $20.

I know I’m sure I can use Goal Seek however I need to have it be a formula to be applied to the range of number variations.

Example below
Values the largest number is where these need to be divisible down to a whole number that is lower

144
24
72
50
45
5
2


these each have different prices
Value. Price
144. 3.25
24. 0.80
72. 9.75
50. 4.33
45. 1.24
5. 8.76
2. 0.22

So for instance with the 144 value that has a price of 3.25, what is the nearest whole number the 144 can be broken down to to make the total value of that multiples by the price to be near $20? Like how many units are needed to be divided down using the 144 that would be a whole number to be close either above or slightly below $20 order value?

PriceValueDivisible number from the Value columnOrder ValueNotes/DetailsPossible divisible numberOrder valueDetails
3.25144'=B2/xxx=C2*A2Need to divide 144 by a number that will be a whole number but that number needs to be the closest value that will be near $20.=144/24 which comes to 6=6 *3.25 which comes to 19.50I did this manually but need a formula to copy down for all cells to do the calculation
0.824
9.7572
4.3350
1.2445
8.765
0.222
Range for order value
$20

Also asked here Help with formula to be divisible by a whole number
 
Last edited by a moderator:

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Here is something. It's not good with small numbers or prime numbers. It's 365.
MrExcelPlayground18.xlsx
ABCD
120
2PriceValueAmountCheck
33.25144619.5
40.8242419.2
59.7572219.5
64.3350521.65
71.24451518.6
88.765543.8
90.22220.44
Sheet4
Cell Formulas
RangeFormula
C3:C9C3=LET(x,B3,y,A3,t,$A$1,a,SEQUENCE(x/2+1),b,x/a,c,FILTER(b,INT(b)=b),d,ABS(y*c-t),e,MIN(d),FILTER(c,d=e))
D3:D9D3=A3*C3
 
Upvote 0
Another option for 365
Fluff.xlsm
ABCD
1PriceValueDivisible number from the Value columnOrder Value
23.25144619.5
30.8242520
49.7572219.5
54.3350521.65
61.24451619.84
78.765217.52
80.2229120.02
9
10
11Range for order value
1220
Lists
Cell Formulas
RangeFormula
C2:D8C2=LET(s,B2/(B2*A2/$A$12),x,INT(s),y,CEILING(s,1),xa,ABS(A2*x-$A$12),ya,ABS(A2*y-$A$12),IF(xa=MIN(xa,ya),HSTACK(x,x*A2),HSTACK(y,y*A2)))
Dynamic array formulas.
 
Upvote 0
I was definitely over-thinking it. A far simplar solution has been posted on Chandoo by @bosco_yip
Excel Formula:
=ROUND(A$12/A2,0)
 
Upvote 0
But that always going to be a whole divisor of the B column?
 
Upvote 0
It gives the same results as I get, but then it depends on how you read the question as to whether it's right or not.
 
Upvote 0
Col A=Sl No, Col B=Price, Col C = Value, Col D ="Amount Col E= Check value
In D2
Excel Formula:
=IF(ABS(INT(CEILING(20,$B2)/$B2)*$B2-20)>ABS(INT((CEILING(20,$B2)/$B2)-1)*$B2-20),INT((CEILING(20,$B2)/$B2)-1),INT((CEILING(20,$B2)/$B2)))
In E2
=B2*D2
 
Upvote 0
Have you actually tested that formula?
 
Upvote 0
Col A=Sl No, Col B=Price, Col C = Value, Col D ="Amount Col E= Check value
For 365 version
In D2
Excel Formula:
=LET(a,INT(CEILING(20,$B2)/$B2),IF(ABS(a*$B2-20)>ABS((a-1)*$B2-20),a-1,a))
In E2
=B2*D2
 
Upvote 0
That still doesn't work. Why not test your ideas before posting. ;)
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,885
Members
452,364
Latest member
springate

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