Function sbRndDecPlace(dmin As Double, dmax As Double, _
Optional ldecplaces As Long = 0) As Double
'Creates a random number between dmin and dmax with
'ldig decimal places. All possible (dmax - dmin) *
'10 ^ ldig + 1 values appear with same likelihood.
'https://berndplumhoff.gitbook.io/sulprobil/excel/excel-vba-solutions/sbrnddecplace
'V0.3 28.08.2020 (C) (P) by Bernd Plumhoff
Static bRandomized As Boolean
If Not bRandomized Then
Randomize
bRandomized = True
End If
sbRndDecPlace = Int((dmax - dmin + 10 ^ -ldecplaces) * _
10 ^ ldecplaces * Rnd) * 10 ^ -ldecplaces + dmin
End Function