|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub tt()
- Dim Arr, Drr, Brr() As Integer, x&, y&, i&, N&, H&, d As Object
- Set d = CreateObject("scripting.dictionary")
- Arr = Range("b3:e" & Cells(Rows.Count, 2).End(xlUp).Row).Value
- ReDim Brr(1 To UBound(Arr))
- For x = 1 To UBound(Arr)
- d(Arr(x, 1)) = ""
- Next x
- Drr = d.keys
- For i = 0 To UBound(Drr)
- N = 0: H = 1
- For x = 1 To UBound(Arr)
- If Arr(x, 1) = Drr(i) And Brr(x) = 0 Then
- If N + Arr(x, 4) <= 30 Then
- Brr(x) = H: N = N + Arr(x, 4)
- Else
- For y = x + 1 To UBound(Arr)
- If N + Arr(y, 4) <= 30 Then Brr(y) = H: N = N + Arr(y, 4)
- Next y
- H = H + 1: N = 0
- Brr(x) = H: N = N + Arr(x, 4)
- End If
- End If
- Next x, i
- Range("g3").Resize(UBound(Arr), 1) = WorksheetFunction.Transpose(Brr)
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|