|
提取O列后面的数据。
- Sub ykcbf() '//2024.8.19
- Set fso = CreateObject("scripting.filesystemobject")
- Set d = CreateObject("Scripting.Dictionary")
- Application.ScreenUpdating = False
- Set sh = ThisWorkbook.Sheets("Sheet1")
- p = ThisWorkbook.Path & ""
- b = [{"f7","f57","f108","f156","f204","f254","f304","f354","f404","f454"}]
- For Each f In fso.GetFolder(p).Files
- If LCase$(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("Report")
- s = .Cells(4, "aw").Value & "|" & .Cells(4, "bh").Value
- st = ""
- For x = 1 To UBound(b)
- tt = .Range(b(x)).Value
- st = st & "|" & tt
- Next
- d(s) = fn & "|" & Mid(st, 2)
- End With
- wb.Close False
- End If
- End If
- Next f
- With sh
- .[o4:z1000] = ""
- r = .Cells(Rows.Count, 2).End(3).Row
- For i = 4 To r
- s = .Cells(i, "c").Value & "|" & .Cells(i, "n").Value
- If s <> Empty Then
- If d.exists(s) Then
- t = Split(d(s), "|")
- For j = 0 To UBound(t)
- .Cells(i, j + 15).Value = t(j)
- Next
- End If
- End If
- Next
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|