num = CCur(Rnd() * 10 ^ Int((Rnd * 10) - 5))
Dim pwr As Double
Dim num As Double
pwr = Rnd()
pwr = 10 ^ Int(pwr * 8 - 5)
num = Int(Rnd() * 9999 + 1)
num = num * pwr
Debug.Print num
sample result: 289562.463760376Nope Only 4 significant figures
You stated that you wanted a "number with 4 significant figures". That generally means that you want a floating point number with a precision of four digits to the right of the decimal point.examples of 4 significant figures are
Int(Rnd() * 1000)
Num = Int(Rnd() * 1000) * 10^(Int(Rnd() *11)-8)
num= Int(Rnd()*9000+1000) * 10 ^ Int((Rnd * 16) - 8)
Sample data from the above:Do
tempNum=Int(Rnd()*9000+1000)
Loop Until (tempNum Mod 10)<>0
num= tempNum * 10 ^ Int((Rnd * 16) - 8)
Dim num As Double
Dim origNum As Double
Dim tempNum As Double
Dim iCntr As Integer
For iCntr = 1 To 100
Do
origNum = Rnd
tempNum = Int(origNum * 9000 + 1000)
'If tempNum Mod 10 = 0 Then
' Debug.Print ;
'End If
Loop Until (tempNum Mod 10) <> 0
num = tempNum * 10 ^ Int((Rnd * 16) - 8)
Debug.Print origNum; tempNum; num 'Int(num * 9000 + 1000) * 10 ^ Int((Rnd * 16) - 8)
Next
If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
Basic Excel DataEntry for Dashboard analysis | 3 | 26 | |
Best Excel formula for this scenario | 2 | 39 | |
Delete all empty columns using VBA | 7 | 42 | |
Merging spreadsheets | 8 | 43 |
Join the community of 500,000 technology professionals and ask your questions.