|
Sub 交易完成_单击()
Dim i As Integer
Dim j As Integer
Dim productname As String
Dim companyname As String
Dim senddate As Date
Dim qty As Integer
Dim datematch As Integer
With Sheets("小杨发货")
For i = 9 To .Cells(6, 3) + 8
companyname = .Cells(7, 3)
productname = .Cells(i, 4) & .Cells(i, 5) & .Cells(i, 6)
qty = .Cells(i, 7)
senddate = .Cells(i, 2)
If companyname <> "" And productname <> "" And qty <> 0 And senddate <> 0 Then
With Sheets("发货单")
j = 1
Do Until j > Application.WorksheetFunction.CountA(.Range("发货单_产品型号"))
If companyname = .Cells(j + 1, 1) And productname = .Cells(j + 1, 2) Then
datematch = Application.WorksheetFunction.Match(Sheets("小杨发货").Cells(i, 2), .Range("发货单_日期"), 0) + 2
.Cells(j + 1, datematch) = qty + .Cells(j + 1, datematch)
datematch = 0
GoTo 1
Else
j = j + 1
End If
Loop
.Cells(j, 1) = companyname
.Cells(j, 2) = productname
datematch = Application.WorksheetFunction.Match(Sheets("小杨发货").Cells(i, 2), .Range("发货单_日期"), 0) + 2
.Cells(j, datematch) = qty
End With
Else
MsgBox ("输入项不能为空,请重新输入")
End If
1:
Next i
End With
End Sub |
|