'先前上面发的少了一行代码
Option Explicit
Sub 查询入库单号()
Dim Arr As Variant, Brr As Variant
Dim fk As Long, hh As Long, js As Long
fk = Sheets("总表").Cells(Rows.Count, 1).End(xlUp).Row
Arr = Sheets("总表").Range("A1").Resize(fk, 1)
fk = Sheets("分表").Cells(Rows.Count, 1).End(xlUp).Row - 3
Brr = Sheets("分表").Range("A4").Resize(fk, 13)
ReDim Crr(1 To fk, 1 To 11) As Variant
For hh = 1 To fk
If Not IsNumeric(Application.Match(Brr(hh, 1), Arr, 0)) Then
js = js + 1
Crr(js, 1) = Brr(hh, 1)
Crr(js, 2) = Brr(hh, 2)
Crr(js, 3) = Brr(hh, 4)
Crr(js, 4) = Brr(hh, 10)
Crr(js, 5) = Brr(hh, 11)
Crr(js, 6) = Brr(hh, 13)
Crr(js, 7) = Brr(hh, 5)
Crr(js, 8) = Brr(hh, 6)
Crr(js, 10) = Brr(hh, 7) '单位
Crr(js, 11) = Brr(hh, 8)
End If
Next hh
If js > 0 Then
fk = Sheets("总表").Cells(Rows.Count, 1).End(xlUp).Row + 1
Sheets("总表").Cells(fk, 1).Resize(js, 11) = Crr
fk = Sheets("总表").Cells(Rows.Count, 1).End(xlUp).Row
Sheets("总表").Sort.SortFields.Clear
'Sheets("总表").Range("A1").Resize(fk, 11).Sort key1:=Sheets("总表").Range("A1"), order1:=xlAscending, Header:=xlYes '以入库单号排序升序
Sheets("总表").Range("A1").Resize(fk, 11).Sort key1:=Sheets("总表").Range("B1"), order1:=xlAscending, Header:=xlYes '以入库日期排序升序
End If
End Sub
4.27.rar
(43.14 KB, 下载次数: 3)
|