level 1
饕餮听哈哈哈
楼主
Sub宏1()
宏1
参数设置
Dim r,m,u,v
m = Val(InputBox("你要生成多少行题目:(输入数字)", , 20))
u = Val(InputBox("你要生成几以内的运算题:(输入数字)", , 100))
v = Val(InputBox("只需要加减法请输入2;加减乘除都需要请输入4:(输入数字)", , 4))
Range(Cells(2, 1), Cells(m, 10)).Select
Selection.ClearContents '清除选区内容
r = 2
循环体
Do 'doloop语句表示执行返回直到情况为止
Cells(r, 1) = WorksheetFunction.RandBetween(1, u)
Cells(r, 3) = WorksheetFunction.RandBetween(1, u)
Cells(r, 6) = WorksheetFunction.RandBetween(1, u)
Cells(r, 8) = WorksheetFunction.RandBetween(1, u)
k = WorksheetFunction.RandBetween(1, v)
Cells(r, 4) = "="
Cells(r, 9) = "="
If k = 1 Then
Cells(r, 2) = "+"
Cells(r, 7) = "+"
Else
If k = 2 Then
Cells(r, 2) = "-"
Cells(r, 7) = "-"
Else
If k = 3 Then
Cells(r, 2) = "×"
Cells(r, 7) = "×"
Else
If k = 4 Then
Cells(r, 2) = "÷"
Cells(r, 7) = "÷"
Else
End If
End If
End If
End If
r = r + 1
Loop Until r = m
设置打印区
Range(Cells(2, 1), Cells(m, 10)).Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.ColumnWidth = 8.11
.RowHeight = 26.4
End With
Selection.Font.Size = 16
Cells(1, 1) = "出题日期"
Range(Cells(1, 1), Cells(1, 2)).Select
Selection.Merge
Range(Cells(1, 3), Cells(1, 4)).Select
Selection.Merge
Selection.NumberFormatLocal = "yyyy/m/d"
Cells(1, 3) = Now()
End Sub
dim后面的r,就开始报错了。该怎么改啊?
2024年11月06日 03点11分
1
宏1
参数设置
Dim r,m,u,v
m = Val(InputBox("你要生成多少行题目:(输入数字)", , 20))
u = Val(InputBox("你要生成几以内的运算题:(输入数字)", , 100))
v = Val(InputBox("只需要加减法请输入2;加减乘除都需要请输入4:(输入数字)", , 4))
Range(Cells(2, 1), Cells(m, 10)).Select
Selection.ClearContents '清除选区内容
r = 2
循环体
Do 'doloop语句表示执行返回直到情况为止
Cells(r, 1) = WorksheetFunction.RandBetween(1, u)
Cells(r, 3) = WorksheetFunction.RandBetween(1, u)
Cells(r, 6) = WorksheetFunction.RandBetween(1, u)
Cells(r, 8) = WorksheetFunction.RandBetween(1, u)
k = WorksheetFunction.RandBetween(1, v)
Cells(r, 4) = "="
Cells(r, 9) = "="
If k = 1 Then
Cells(r, 2) = "+"
Cells(r, 7) = "+"
Else
If k = 2 Then
Cells(r, 2) = "-"
Cells(r, 7) = "-"
Else
If k = 3 Then
Cells(r, 2) = "×"
Cells(r, 7) = "×"
Else
If k = 4 Then
Cells(r, 2) = "÷"
Cells(r, 7) = "÷"
Else
End If
End If
End If
End If
r = r + 1
Loop Until r = m
设置打印区
Range(Cells(2, 1), Cells(m, 10)).Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.ColumnWidth = 8.11
.RowHeight = 26.4
End With
Selection.Font.Size = 16
Cells(1, 1) = "出题日期"
Range(Cells(1, 1), Cells(1, 2)).Select
Selection.Merge
Range(Cells(1, 3), Cells(1, 4)).Select
Selection.Merge
Selection.NumberFormatLocal = "yyyy/m/d"
Cells(1, 3) = Now()
End Sub
dim后面的r,就开始报错了。该怎么改啊?