|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
想设计一个小学分数的加法的自动出题 VBA 结果有些地方的格式不对,不是出现日期就是出现一个很大的数学,而不是分数.请教高手兄.
Sub 分数加法()
Dim i, a, b, c, d, e
Range("A2:F110").ClearContents
Cells(1, 1) = "编号": Cells(1, 2) = "被加数": Cells(1, 3) = "+": Cells(1, 4) = "加数": Cells(1, 5) = "=": Cells(1, 6) = "和":
For i = 2 To 11
Cells(i, 1) = i - 1
b = Int(99 * Rnd + 1)
c = Int(99 * Rnd + 1)
d = Int(99 * Rnd + 1)
e = Int(99 * Rnd + 1)
Range("b2:f11").Select
Selection.NumberFormatLocal = "# ?/?"
If b > c Then Cells(i, 2) = c & " / " & b Else Cells(i, 2) = b & " / " & c
If d > e Then Cells(i, 4) = e & " / " & d Else Cells(i, 4) = d & " / " & e
Cells(i, 3) = "+"
Cells(i, 5) = "="
Next i
End Sub
|
|