用函数公式就行了,要不你自己改为VBA吧。
C1==IF(B1="A",INT(RAND()*5+95), IF(B1="B",INT(RAND()*9+85),IF(B1="c",INT(RAND()*9+75),IF(B1="D",INT(RAND()*14+60),""))))
就是说:
95-100=INT(RAND()*5+95)
85-94=INT(RAND()*9+85)
75-84=INT(RAND()*9+75)
60-74=INT(RAND()*14+60)
试下下面的代码
Sub 随机取数()
Dim arr, r
arr = Range("b1:b8")
ReDim Preserve arr(1 To UBound(arr), 1 To 2)
For r = 1 To UBound(arr)
Select Case arr(r, 1)
Case Is = "A"
arr(r, 2) = Int(Rnd() * 5) + 95
Case Is = "B"
arr(r, 2) = Int(Rnd() * 9) + 85
Case Is = "C"
arr(r, 2) = Int(Rnd() * 9) + 75
Case Is = "D"
arr(r, 2) = Int(Rnd() * 14) + 60
End Select
Next r
Range("b1").Resize(UBound(arr), 2) = arr
End Sub