Kevin
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
Title | # Comments | Views | Activity |
---|---|---|---|
Macro to Send Appointment from Excel | 1 | 27 | |
Excel 2016 - Dotted line appears, but it's not a page break | 14 | 29 | |
second highest value difference | 11 | 23 | |
Populate data based ona criteria | 6 | 5 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
14 Experts available now in Live!