|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub 按钮2_Click()
- a = -1
- r = 0
- Dim arr(1 To 3)
- Application.ScreenUpdating = False
- For j = 390 To (390 / 2) - 10 Step -1
- a = a + 1
- x = 1
- arr(1) = j
- sm = Cells(j, 1)
- For i = 1 To 390 / 2
- If Cells(i, 1) > 0 Then
- sm = sm + Cells(i, 1)
- x = x + 1
- arr(x) = i
- If sm >= 40 Then
- Exit For
- Else
- If x = 3 Then
- If sm <= 39 Then
- Exit For
- Else
- r = r + 1
- For k = 1 To 3
- Cells(r, 8 + k) = Cells(arr(k), 1)
- Cells(arr(k), 1) = 0
- Next k
- Exit For
- End If
- Else
- If sm > 39 And sm < 40 Then
- r = r + 1
- For k = 1 To 2
- Cells(r, 8 + k) = Cells(arr(k), 1)
- Cells(arr(k), 1) = 0
- Next k
- Exit For
- End If
- End If
- End If
- End If
- Next i
- Next j
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|