|
按你要求第14句c>=c1改成c>c1。另外最接近你原来代码的改法如下 :- Private Sub CommandButton1_Click()
- Dim dInput As Double
- Dim r As Integer
- r = Sheet1.Range("B65536").End(xlUp).Row
- x = Application.InputBox(Prompt:="请设置分组人数:", Type:=1)
- c1 = Application.InputBox(Prompt:="请设置最大余数:", Type:=1)
- For i = 3 To r
- a = Sheet1.Cells(i, 3).Value
- C = a Mod x
- If x > a Then
- Sheet1.Cells(i, 5) = Int(a / x) + 1
- ElseIf x <= a And c1 >= C Then
- Sheet1.Cells(i, 5) = Int(a / x)
- Else
- Sheet1.Cells(i, 5) = Int(a / x) + 1
- End If
- Next i
- End Sub
复制代码 |
|