|
参与一下。。。- Sub ykcbf() '//2024.1.20
- Set Fso = CreateObject("scripting.filesystemobject")
- Application.ScreenUpdating = False
- Set sh = ThisWorkbook.Sheets("参数")
- st = sh.[b1].Value
- b = [{6,2,3}]
- ReDim brr(1 To 1000, 1 To 3)
- p = ThisWorkbook.Path & "\数据库"
- For Each sht In Sheets
- If sht.Name = st Then sht.Delete
- Next
- For Each f In Fso.GetFolder(p).Files
- If f.Name Like "*.xlsx" Then
- fn = Fso.GetBaseName(f)
- Set wb = Workbooks.Open(f, 0)
- With wb.Sheets(1)
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .Range("a1:f" & r)
- wb.Close False
- End With
- For i = 3 To UBound(arr)
- s = arr(i, 2) & arr(i, 3)
- If InStr(s, st) Then
- m = m + 1
- For j = 1 To UBound(b)
- brr(m, j) = arr(i, b(j))
- Next
- End If
- Next
- End If
- Next f
- Sheets("模板").Copy after:=Sheets("参数")
- Set sht = ActiveSheet
- With sht
- .Name = st
- If m > 0 Then
- .[a2].Resize(m, 3) = brr
- .[a2].Resize(m, 3).EntireColumn.AutoFit
- End If
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|