|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
参与一下。。。
- Sub ykcbf() '//2024.7.21 CSV文件导入
- Set fso = CreateObject("scripting.filesystemobject")
- Application.ScreenUpdating = False
- Set sh = ThisWorkbook.Sheets("原始数据")
- sh.UsedRange.Clear
- p = ThisWorkbook.Path & ""
- For Each f In fso.GetFolder(p).Files
- If UCase$(f.Name) Like "*.CSV" Then
- m = m + 1
- Set wb = Workbooks.Open(f, 0)
- With wb.Sheets(1)
- If m = 1 Then
- .UsedRange.Copy sh.[a1]
- Else
- r = sh.Cells(Rows.Count, 1).End(3).Row
- .UsedRange.Offset(1).Copy sh.Cells(r + 1, 1)
- End If
- End With
- wb.Close False
- End If
- Next f
- With sh
- r = .Cells(Rows.Count, 1).End(3).Row
- For i = 2 To r
- .Cells(i, 1) = i - 1
- Next
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
2
查看全部评分
-
|