早教吧 育儿知识 作业答案 考试题库 百科 知识分享

excel宏程序X1=31,X2=65X3=30~43之间的整数,X4=88~124之间的整数X5=14~18之间的整数,或等于27,X6,X7=10,或14~18之间的整数,X8=34~38之间的整数,或等于40,k=(x1*x3*x5*x8)/x2*x2*x6*x7,求1.206466667

题目详情
excel 宏程序 X1=31,X2=65 X3=30~43之间的整数,X4=88~124之间的整数 X5=14~18之间的整数,或等于27,X6,X7=10,或14~18之间的整数,X8=34~38之间的整数,或等于40,k=(x1*x3*x5*x8)/x2*x2*x6*x7,求 1.206466667
▼优质解答
答案和解析
Sub kkk()
X1 = 31
X2 = 65
Dim X3 As Variant
X3 = Array(30,31,32,33,34,35,36,37,38,39,40,41,42,43)
Dim X4(37) As Variant
For i = 0 To 36
X4(i) = i + 88
Next i
Dim X5 As Variant
X5 = Array(14,15,16,17,18,27)
X6 = 10
X7 = 10
Dim X8 As Variant
X8 = Array(34,35,36,37,38,40)
rn = 2
Sheets(1).Cells(1,1) = "X3"
Sheets(1).Cells(1,2) = "X4"
Sheets(1).Cells(1,3) = "X5"
Sheets(1).Cells(1,4) = "X8"
For i = 0 To 13
For j = 0 To 36
For m = 0 To 5
For n = 0 To 5
k = (X1 * X3(i) * X5(m) * X8(n)) / X2 / X2 / X6 / X7
If 1.206466667 < k < 1.206866667 Then
Sheets(1).Cells(rn,1) = X3(i)
Sheets(1).Cells(rn,2) = X4(j)
Sheets(1).Cells(rn,3) = X5(m)
Sheets(1).Cells(rn,4) = X8(n)
rn = rn + 1
End If
Next n
Next m
Next j
Next i
End Sub
结果都输出到sheet1里
我感觉这个计算的式子 k = (X1 * X3(i) * X5(m) * X8(n)) / X2 / X2 / X6 / X7有点问题,运行了一下,有几千上万的组合.