|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub 按钮1_Click()
- Application.ScreenUpdating = False
- arr = Range("a1:ag31")
- For j = 2 To UBound(arr)
- If Len(arr(j, UBound(arr, 2))) > 0 And j <> 32 Then
- x = WorksheetFunction.CountA(Cells(j, 1).Resize(1, UBound(arr, 2)))
- If x < UBound(arr, 2) Then
- a = UBound(arr, 2) - x
- sm = arr(j, UBound(arr, 2))
- For i = 2 To UBound(arr, 2) - 1
- If Len(arr(j, i)) = 0 Then
- If a Mod 2 = 0 Then
- arr(j, i) = (Int(sm / a) - 0.5)
- sm = sm - arr(j, i)
- a = a - 1
- Else
- If a = 1 Then
- arr(j, i) = sm
- Else
- arr(j, i) = (Int(sm / a) + 0.5)
- sm = sm - arr(j, i)
- a = a - 1
- End If
- End If
- End If
- Next i
- End If
- End If
- Next j
- Range("a1:ag31") = arr
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|