批处理多个EXCEL的内容
如何同时通过外部的VB或VBA实现同时对多个EXCEL内容的修改替换如,将D盘li文件夹中的所有的EXCEL的cells(1,1)替换成1999...
如何同时 通过外部的VB或VBA 实现 同时对多个EXCEL 内容的修改替换
如,将D 盘 li文件夹中的所有的EXCEL的cells(1,1)替换成 1999 展开
如,将D 盘 li文件夹中的所有的EXCEL的cells(1,1)替换成 1999 展开
展开全部
Sub Macro1()
Application.DisplayAlerts = False
nopathfilename1 = ActiveWorkbook.Name
'统计文件名
pathfile = "D:\li"
'统计文件目录
Dim sFolder As String
Dim wb As Workbook
Dim i As Long
With Application.FileSearch
.NewSearch
.LookIn = pathfile
.SearchSubFolders = True
.Filename = "*.xls"
.FileType = msoFileTypeExcelWorkbooks
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
On Error Resume Next
Filename = .FoundFiles(i)
Workbooks.Open Filename:=Filename
Range("A1")=1999
ActiveWorkbook.Save
ActiveWindow.Close
End If
Next i
Else
MsgBox "Folder " & sFolder & " 没发现文件!"
End If
End With
Application.DisplayAlerts = True
End Sub
Application.DisplayAlerts = False
nopathfilename1 = ActiveWorkbook.Name
'统计文件名
pathfile = "D:\li"
'统计文件目录
Dim sFolder As String
Dim wb As Workbook
Dim i As Long
With Application.FileSearch
.NewSearch
.LookIn = pathfile
.SearchSubFolders = True
.Filename = "*.xls"
.FileType = msoFileTypeExcelWorkbooks
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
On Error Resume Next
Filename = .FoundFiles(i)
Workbooks.Open Filename:=Filename
Range("A1")=1999
ActiveWorkbook.Save
ActiveWindow.Close
End If
Next i
Else
MsgBox "Folder " & sFolder & " 没发现文件!"
End If
End With
Application.DisplayAlerts = True
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询