Choose a random value between 0.00 and 20.00 - excel

In Excel, it is possible to select a random value from a set of 5 options in the following manner:
Values
e.g. 15, 30, 50, 75, or 100
Formula
=CHOOSE(RANDBETWEEN(1,5),15,30,50,75,100)
If I wanted to select a value from a much denser range how would I do it?
e.g. 0.00, 0.01, 0.02, 0.03 ,0.04 ,0.05 ... 19.95, 19.96, 19.97, 19.98, 20.00
What would be the correct formulae?

Consider the following formula:
=0.01*RANDBETWEEN(0,2000)
This will produce random multiples of .01

Scale the output of the random function by multiplying/dividing it by a constant.
For instance, if your Random function outputs floating decimal values between 0 and 1, and you need outputs between 0 and 100, multiply the output of the random function by 100.
If you need the final result to be an integer, you can then round the value to the nearest integer.
It sounds like you want
=ROUND(RAND()*20,2)
The 20 is the maximum value of your zero-to-maximum range, and the 2 is how many decimal places it'll round the final output to.

Related

How to change count after certain value

I'm trying to write a code in Excel that basically counts multiplies valueA by 5 when ValueA<=15. Once valueA surpasses 15 (therefore ValueA>15), it will the multiply ValueA by 9 for the remaining amount value. For example, if ValueA=20, 1-15 will be multiplied by 5, and the 16-20 will be multiplied by 9, to give the total amount.
Can anybody else out with this?
So far, I have:
=IF(AND(A2="LR",B2<=15),B2*5, IF(AND(A2="LR",B2>16....
not sure how to finish off!
=IF(AND(A2="LR",B2<=15),B2*5, IF(AND(A2="LR",B2>15),B2*9-75, ... Whatever value you want if A2 doesn't equal LR))

Loop through row multiplying by one row VBA

I have a set of weights in rows BA40:BZ40 and I want each row starting from BA60:BZ60 to sum (BA40*BA60 + BB40*BB60 + ... + BZ40*BZ60). Then paste this in CA60 then move onto row 61. However I still need to reference BA40:BZ40. I don't know if its my simplistic mind getting confused or its not possible. However I have learnt everything is possible. My code at the moment is
Dim cellsum As Long
For i = 60 to 1000
So I want to calculate for each day, the weighted sum of the loss. For example day 1, sum(0.2*(-10)+ 0.2*(-8)+ 0.1*(-6) + 0.5(-4))
Weight: 20%, 20%, 10%, 50%
Day 1: -10, -8, -6, -5
Day 2: -9, -8, -7, -6
Day 3: -5, -5, -4, -4
...
Use SUMPRODUCT() function as following. It will automatically calculate percentage. You do not need to sum as .2, .1
=SUMPRODUCT(BA40:BZ40,BA60:BZ60)
Imagine the follwing table:
Then the weighted sum of day 1 would calculate according to your example like …
=SUM($B$1*B3,$C$1*C3,$D$1*D3,$E$1*E3)
which is the same as …
=SUMPRODUCT($B$1:$E$1,B3:E3)
This formula in G3 then can easily pulled/copied down until G5.
So for your data it should be something like the following in cell CA60 …
=SUMPRODUCT($BA$40:$BZ$40,BA60:BZ60)
and then copy down to the other rows.

Dynamic score within range based on value

I am attempting to score a record based on where it's value falls within a range. I know I can create a lookup table but that would be rather time intensive and was hoping for additional options.
Example:
Lower bound of 0
Upper bound of 90
Record has a score of 67
What I want to do is score that record between 1 - 3 based on where the value of 67 falls within the range of 10 - 90. So in this instance this record would score a 2.25, or the like.
Thank you in advance for your assistnace!
This is a simple linear equation
With 67 in A1, in A2 enter:
=A1*0.025+1
and then apply rounding.
The 0.025 comes from =(3-1)/(90-10)
The above chart shows the mapping of records between 10 and 90 into scores between 1 and 3.
Assuming the score is linear, the following formula should work
=Record/(UpperRange - Lower Range)*2+1
In the example you give, this would be: 67/(90-10)*2+1 and the result would be 2.675
If you want the scores to go from 1 to 3, in 0.25 increments, with a lower bound of 0, and upper of 90, then:
=ROUNDDOWN(SCORE/(90/8),0)*0.25+1
Which gives 2.25

Generate a random range of numbers in excel

I'm looking for an excel formula to generate a random range of numbers between -0.3 and +0.3. These numbers can be at most 2 decimal places.
E.g here is a list of numbers I would expect this formula to return:
-0.24, 0.02, 0.13, -0.14, 0.3, 0.22, -0.29
and so on...
Many thanks
thats quite easy to do:
=RANDBETWEEN(-30;30)/100

origin value and after sum after ROUND() is different

I have a table with "ordered amount", "percentages", and "total sum". Note that "ordered amount" and "total sum" should be the same.
column F= sum of C:F
*rows 4,6,8,10 used =round()
As shown in the table(image), for some numbers, value in F is not the same as A when it should be. (e.g. A6(105) and F7(104), -1 after rounding).
Is there anyway to avoid this?
Thank you very much.
If the sum of the decimal points adds up to > 5, your final rounded number will round up. If they add up to < 5, the final number will round down.
Consider this example:
10.5 + 5 = 15.5, which rounds to 16.
However
10 + 5 = 15
This is what is happening in your table.
In order to get the sum of rounded numbers to add up to the same as the sum of the numbers, in your example, you will need to NOT round, but rather subtract, one of the values. I would suggest altering the largest value, as it would seem to have the least effect on the percentages, but that is a choice you can make.
To do that, with your data in row 8, for example you could do the following.
A9: =IF(B$8=MAX($B$8:$E$8),SUM($B$8:$E$8)-SUM(ROUND($B$8:$E$8,0))+ROUND(B$8,0),ROUND(B$8,0))
entered as an array formula with ctrl+shift+enter and fill right to E9.
This would give a sum of 344 which is the same as F8

Resources