|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 批量操作()
Application.ScreenUpdating = False
ljj = ThisWorkbook.Path
VBA.ChDir ljj
Set dlgOpen = Application.FileDialog(msoFileDialogFolderPicker)
With dlgOpen
If .Show <> -1 Then MsgBox "您没有选择文件夹!": Exit Sub
lj = .SelectedItems(1)
End With
f = Dir(lj & "\*.csv")
Do While f <> ""
If f <> ThisWorkbook.Name Then
Set wb = Workbooks.Open(lj & "\" & f)
sl = Len(Trim(wb.Name))
mc = Mid(wb.Name, 1, sl - 4)
With wb.Worksheets(1)
r = .Cells(Rows.Count, 1).End(xlUp).Row
.Rows(r).Delete
.Rows("1:5").Delete
.Range("a1:c" & r).NumberFormatLocal = "0.00000000000000_ ;[红色]-0.00000000000000 "
End With
wb.SaveAs Filename:=ljj & "\txt文件\" & mc & ".txt", FileFormat:=xlText, CreateBackup:=False
wb.Close
End If
f = Dir
Loop
Application.ScreenUpdating = True
MsgBox "操作完毕!"
End Sub
|
|