|
Sub 匹配()
Application.ScreenUpdating = False
Dim ar As Variant, br As Variant
Dim i As Long, r As Long, rs As Long
Dim d As Object
Set d = CreateObject("scripting.dictionary")
lj = ThisWorkbook.Path & "\"
f = Dir(lj & "双丰导出因子表.xls*")
If f = "" Then MsgBox "找不到双丰导出因子表文件,请核查后重试!": End
Set wb = Workbooks.Open(lj & f, 0)
With wb.Worksheets(1)
r = .Cells(Rows.Count, 6).End(xlUp).Row
If r < 2 Then MsgBox "双丰导出因子表为空!": End
ar = .Range("a1:hr" & r)
End With
wb.Close False
For i = 2 To UBound(ar)
If ar(i, 6) <> "" And ar(i, 10) <> "" And ar(i, 12) <> "" Then
s = ar(i, 6) & "|" & ar(i, 10) & "|" & ar(i, 12)
d(s) = i
End If
Next i
Set f = Nothing
f = Dir(lj & "双丰批次_总表.xls*")
If f = "" Then MsgBox "找不到双丰批次_总表文件,请核查后重试!": End
Set wb = Workbooks.Open(lj & f, 0)
With wb.Worksheets("采伐调查设计总表(CFDCSJZB)")
rs = .Cells(Rows.Count, 2).End(xlUp).Row
If rs < 5 Then MsgBox "采伐调查设计总表(CFDCSJZB)!": End
br = .Range("a4:t" & rs)
For i = 2 To UBound(br)
If br(i, 1) <> "" And br(i, 3) <> "" And br(i, 5) <> "" Then
s = br(i, 1) & "|" & br(i, 3) & "|" & br(i, 5)
xh = d(s)
If xh <> "" Then
br(i, 19) = ar(xh, 224)
br(i, 20) = ar(xh, 225)
End If
End If
Next i
.Range("a4:t" & rs) = br
End With
With wb.Worksheets("采伐证申请表(CFZSQB)")
rs = .Cells(Rows.Count, 2).End(xlUp).Row
If rs < 5 Then MsgBox "采伐证申请表(CFZSQB)为空!": End
br = .Range("a4:v" & rs)
For i = 2 To UBound(br)
If br(i, 3) <> "" And br(i, 4) <> "" And br(i, 6) <> "" Then
s = br(i, 3) & "|" & br(i, 4) & "|" & br(i, 6)
xh = d(s)
If xh <> "" Then
br(i, 21) = ar(xh, 224)
br(i, 22) = ar(xh, 225)
End If
End If
Next i
.Range("a4:v" & rs) = br
End With
wb.Close True
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
评分
-
1
查看全部评分
-
|