|
- Public d
- Public a
- Public arr
- Public m
- Sub lqxs_zd()
- Application.ScreenUpdating = False
- ActiveSheet.UsedRange.Offset(1, 2).ClearContents
- Set d = CreateObject("scripting.dictionary")
- arr = [a1].CurrentRegion
- a = 3
- m = [e1].Value
- For j = 2 To UBound(arr)
- If arr(j, 2) < m Then
- d(j) = arr(j, 2)
- dg j
- If d.Count > 0 Then d.Remove j
- Else
- If arr(j, 2) = m Then
- Cells(2, a) = arr(j, 2)
- a = a + 1
- End If
- End If
-
- Next j
- Application.ScreenUpdating = True
- End Sub
- Sub dg(y)
- For j = y + 1 To UBound(arr)
- sm = WorksheetFunction.Sum(d.items)
- If sm + arr(j, 2) = m Then
- d(j) = arr(j, 2)
- Cells(2, a).Resize(d.Count) = WorksheetFunction.Transpose(d.items)
- a = a + 1
- d.Remove j
- Else
- If sm + arr(j, 2) < m Then
- d(j) = arr(j, 2)
- dg j
- End If
- End If
- If d.exists(j) Then d.Remove j
- Next j
- End Sub
复制代码 |
|