|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
参与一下。。。- Sub ykcbf() '//2024.1.18
- Set fso = CreateObject("scripting.filesystemobject")
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set sh = ThisWorkbook.Sheets("Sheet1")
- p = ThisWorkbook.Path & ""
- b = [{2,7}]
- 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("a4:j" & r)
- For x = 1 To 2
- For i = 2 To UBound(arr)
- If arr(i, b(x)) = Empty Then
- arr(i, b(x) + 2) = ""
- arr(i, b(x) + 3) = ""
- End If
- Next
- Next
- .Range("a4:j" & r) = arr
- End With
- wb.Close 1
- End If
- Next f
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|