|
4#
楼主 |
发表于 2018-1-8 17:31:46
|
只看该作者
大神帮忙的,需要可以看哈!
- Private Sub CommandButton1_Click()
- Application.ScreenUpdating = False
- With ThisWorkbook.Worksheets("账目明细")
- Dim iArr, lRow As Long
- lRow = .Range("C" & Rows.Count).End(xlUp).Row
- iArr = .Range("C5:C" & lRow).Value
- ReDim iDrr(UBound(iArr), 2)
- Dim zD As Object, i As Long: Set zD = CreateObject("Scripting.Dictionary")
- For i = 1 To UBound(iArr)
- zD(iArr(i, 1)) = i
- Next i
- End With
- With ThisWorkbook.Worksheets("出入库流水记账簿")
- lRow = .Range("C" & Rows.Count).End(xlUp).Row
- Erase iArr
- iArr = .Range("C5:C" & lRow).Value
- Dim iBrr, iCrr
- iBrr = .Range("K5:L" & lRow).Value
- iCrr = .Range("U5:U" & lRow).Value
- End With
- With ThisWorkbook.Worksheets("账目明细")
- For i = 1 To UBound(iArr)
- If zD.Exists(iArr(i, 1)) Then
- If iBrr(i, 1) < iBrr(i, 2) Or Date - iCrr(i, 1) < 15 Then
- iDrr(zD(iArr(i, 1)), 1) = iDrr(zD(iArr(i, 1)), 1) + iBrr(i, 1)
- ElseIf iBrr(i, 1) = iBrr(i, 2) Or Date - iCrr(i, 1) > 15 Then
- iDrr(zD(iArr(i, 1)), 2) = iDrr(zD(iArr(i, 1)), 2) + iBrr(i, 1)
- End If
- End If
- Next i
- Set zD = Nothing
- .[H5].Resize(UBound(iDrr), 2).Value = iDrr
- End With
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|