|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
更新一下,文件夹改为自选- Sub ykcbf() '//2024.7.24
- Set fso = CreateObject("scripting.filesystemobject")
- Set d = CreateObject("Scripting.Dictionary")
- Set reg = CreateObject("VBScript.Regexp")
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set sh = ThisWorkbook.Sheets("Org2")
- With Application.FileDialog(msoFileDialogFolderPicker)
- .Title = "请选择文件夹"
- .InitialFileName = ThisWorkbook.path & ""
- If .Show = -1 Then
- p = .SelectedItems(1) & ""
- End If
- End With
- With reg
- .Global = False
- .Pattern = "Read|CY|HQ|RFI"
- End With
- For Each f In fso.GetFolder(p).Files
- If LCase$(f.Name) Like "*.xls*" Then
- fn = fso.GetBaseName(f)
- If Not d.exists(fn) Then
- If Not reg.TEST(fn) Then
- d(fn) = ""
- Set wb = Workbooks.Open(f, 0)
- With wb.Sheets(1)
- r1 = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a2].Resize(r1 - 1, 23)
- End With
- wb.SaveAs p & fn & "-Read"
- wb.Close
- r = sh.Cells(Rows.Count, 1).End(3).Offset(1).Row
- sh.Cells(r, 1).Resize(UBound(arr), 23) = arr
- fso.deletefile f
- End If
- End If
- End If
- Next f
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|