Mariana da Costa
Mariana da Costa

Reputation: 173

Generate random numbers between 0.001359 and 1

I was doing a problem and using the function rnd() but the random values <0.001359 were making other values not acceptable.

How to generate random numbers beginning at 0.001359 until 1?

Upvotes: 0

Views: 3873

Answers (3)

Brian Pressler
Brian Pressler

Reputation: 6713

This will give you a random number greater than or equal to 0.001359 and less than 1.

0.001359 + Rnd() * 0.998641

Upvotes: 3

Byron
Byron

Reputation: 429

Try this formula (Excel 2013):

=(RANDBETWEEN(1359,1000000)) / 1000000

Since it only returns whole numbers, just slide the decimal as needed and then divide the result to get back to you decimal.

To do that in VBA, you can use this:

randomnumber = WorksheetFunction.RandBetween(1359, 1000000) / 1000000

Upvotes: 0

Shaulian
Shaulian

Reputation: 427

Try to generate numbers between 1359 and 1000000, and then divide the result by 1000000.

The command for generating the random numbers will be

Int ((1000000 - 1359 + 1) * Rnd + 1359)

For more information look here.

Upvotes: 0

Related Questions