The number needs to have a length of 12 and 2 decimal places.
Probably there's a solution with "=RAND()".
The number needs to have a length of 12 and 2 decimal places.
Probably there's a solution with "=RAND()".
the number would be between 1000000000,00 and 9999999999,99
You can do:
=RANDBETWEEN(1000000000;9999999999)+ROUND(RAND();2)
Because you are working with numbers pretty huge, remember to format the cell as numeric with 2 decimals or you won't see the result!:
Lots of answers, but here is my solution:
=RANDBETWEEN(1000000000,9999999999)+RANDBETWEEN(1,99)/100
This formula will produce a random number and also a random decimal place, decimal numbers produce by dividing the decimal place numbers by 100 and adding them to the whole number.
Make sure you format your cells as number with 2 decimal places.
This is definitely NOT the best way to do it. It is not efficient and there will be far better mathematical approaches but it does work and does guarantee all your requirements. It is also very easy to see what it is doing and adjust if needed.
=CONCAT(
RANDBETWEEN(1000000000,9999999999),
".",
RANDBETWEEN(0,99)
)+0
This constructs the number as a string from two random integers before and after the decimal place.
The +0
simply ensures that Excel treats the result as a number rather than text.
Is it necessary to generate the decimal part separately from the integer part? Maybe you can do this:
=RANDBETWEEN(10^10,10^11-1)/100
formatted as a number (if you want the total length to be 12 including the decimal point).
As suggested by @Gravitate, if you need the length to be twelve not including the decimal point, it would be
=RANDBETWEEN(10^11,10^12-1)/100
Or in general
=LET(n,12,d,2,RANDBETWEEN(10^(n-1),10^n-1)/10^d)
where n is the number of digits excluding the decimal point and d is the number of decimal digits.
But you would need to adjust the format manually or use this to get it to display correctly:
=LET(n,12,d,2,TEXT(RANDBETWEEN(10^(n-1),10^n-1)/10^d,"0."&REPT("0",d)))