|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 清单()
Dim ar As Variant, br As Variant
Dim arr()
With Sheet1
r = .Cells(Rows.Count, 1).End(xlUp).Row
If r < 4 Then MsgBox "购买合同为空!": End
ar = Range("a3:b" & r)
rs = .Cells(Rows.Count, 1).End(xlUp).Row
If rs < 4 Then MsgBox "发货清单为空!": End
br = Range("d3:f" & rs)
ReDim arr(1 To UBound(br), 1 To UBound(br, 2))
For i = 2 To UBound(ar)
If Trim(ar(i, 1)) <> "" Then
For s = 2 To UBound(br)
If Trim(br(s, 1)) = Trim(ar(i, 1)) Then
n = n + 1
For j = 1 To UBound(br, 2)
arr(n, j) = br(s, j)
Next j
End If
Next s
End If
Next i
If n = "" Then End
ws = .Cells(Rows.Count, 9).End(xlUp).Row
If ws > 3 Then .Range("i4:k" & ws) = Empty
.[i4].Resize(n, UBound(arr, 2)) = arr
End With
MsgBox "ok!"
End Sub
|
|