|
参与一下。。。
- Sub ykcbf() '//2024.3.30
- Set sh = ThisWorkbook.Sheets("mrp")
- Set fso = CreateObject("scripting.filesystemobject")
- Set d = CreateObject("Scripting.Dictionary")
- Application.ScreenUpdating = False
- p = ThisWorkbook.Path & ""
- On Error Resume Next
- For Each f In fso.GetFolder(p).Files
- If f.Name Like "*.xls*" Then
- If InStr(f.Name, ThisWorkbook.Name) = 0 Then
- fn = fso.GetBaseName(f)
- Set wb = Workbooks.Open(f, 0)
- With wb.Sheets(fn)
- c = Application.WorksheetFunction.Match("Part number", .Rows(1), 0)
- c1 = Application.WorksheetFunction.Match("Quantity", .Rows(1), 0)
- arr = .UsedRange
- wb.Close False
- End With
- For i = 2 To UBound(arr)
- s = arr(i, c) & "|" & fn
- d(s) = arr(i, c1)
- Next
- End If
- End If
- Next f
- With sh
- r = .Cells(Rows.Count, 3).End(3).Row
- For i = 4 To r
- For j = 10 To 12
- s = .Cells(i, 3) & "|" & .Cells(3, j)
- If d.exists(s) Then
- .Cells(i, j) = d(s)
- Else
- .Cells(i, j) = ""
- End If
- Next
- Next
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
2
查看全部评分
-
|