=RANDBETWEEN and Decimals?

Sub_Diver

New Member
Joined
May 19, 2003
Messages
17
Need help with allowing three decimal places of random numbers generated between two numbers.

so Cell A1 would be 900.000 and Cell B1 would be 1000.000

I'm using:

=RANDBETWEEN(A1, B1)

I need it to give numbers with the decimal also random generated.

>>>What I'm getting 934.000, 978.000, 954.000, 976.000 - etc...

>>>What I'd like to get is 934.876, 978.993, 954.321, 976.107

Need a random 3 decimal places as well...

any ideas?

Thnx
 
jmiskey is correct. I did notice that, but thought it's very unlikely.

Even still, his method is better since it will avoid that possibility.

-Mike D
 
Upvote 0

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Mike,

If your range is very far apart, i.e. 0-1000000, you are right, it is very unlikely. But if it is a small range, like 1-10, the odds get much higher, especially if you are doing a lot of calculations.
 
Upvote 0
That's true. If it were something I were throwing together quickly for myself, I wouldn't have given it much thought. But in hindsight, without knowing more about what diver's situation is, I feel like I should have at least mentioned it when I broke out my solution, and let him decide if it was "close enough"

-Mike D
 
Upvote 0
Sub_Diver

Be careful!

If it selects 1000 in the first part, your result will be over 1000. To see this, try this a few times, seeing that you will get a number greater than one:
=(RANDBETWEEN(0,1)+(ROUND((RAND()),3)))

To avoid going over 1.000 I used "=(RANDBETWEEN(0,0)+(ROUND((RAND()),3)))" and it seems to work.

inchmm
0.2827.16
0.40910.39
0.0060.15
0.2746.96

<colgroup><col><col></colgroup><tbody>
</tbody>
 
Upvote 0
=(RANDBETWEEN(A1,B1)+(ROUND((RAND()),3))) does not work if the values of A1, B1 are <1.

Eg/ A=0.9 B=0.8
Randbetween with round to 1 then add the decimal so your value will be >1 which is not what you want
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,858
Members
449,052
Latest member
Fuddy_Duddy

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