软件:excel
版本:任何版本
If (MsgBox("是否执行取代?", vbYesNo) = vbNo) Then Exit Sub
Application.ScreenUpdating = False '宏执行时不更新萤幕
Dim openfile$, filepath$, thiswrkname$
Dim FileChosen As Integer
Dim ff As String
Dim MM
Dim diaFolder As FileDialog
thiswrkname = ThisWorkbook.Name
'开启资料夹
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
fd.AllowMultiSelect = False
FileChosen = fd.Show
'没有选资料夹离开程式
If FileChosen <> -1 Then
MsgBox "你没有选择资料夹"
Exit Sub
Else
filepath = fd.SelectedItems(1) & "\"
End If
openfile = Dir(filepath & "*.xls*")
Application.DisplayAlerts = False
'资料夹没档案离开程式
If openfile = "" Then
MsgBox "资料夹内没有要处理档案,请确认"
Exit Sub
End If
====
主要是下面这段:
'