这不就是和哥一样的问题嘛,吼吼
Sub ImportData()
Dim MyObject As Object
Dim strPath As String, strFileName As String, strMyName As String
Dim shtSheet As Worksheet, strShtName As String
Dim intCount As Integer, intShtCount As Integer, i As Integer
Application.ScreenUpdating = False
Application.DisplayAlerts = False
strPath = ThisWorkbook.Path
strMyName = ThisWorkbook.Name
intShtCount = ThisWorkbook.Sheets.Count
With Application.FileSearch
.NewSearch
.LookIn = strPath
.SearchSubFolders = False
.Filename = ".xls"
.FileType = msoFileTypeOfficeFiles
If .Execute() > 0 Then
intCount = .FoundFiles.Count
For i = 1 To intCount
strFileName = Replace(.FoundFiles(i), strPath & "\", "")
If strFileName <> strMyName Then
Set MyObject = GetObject(strPath & "/" & strFileName)
For Each shtSheet In MyObject.Worksheets
strShtName = shtSheet.Name
If MyObject.Sheets(strShtName).UsedRange.Count > 1 Then
MyObject.Sheets(strShtName).Copy After:=ThisWorkbook.Sheets(intShtCount)
End If
Next shtSheet
MyObject.Close
End If
Next i
Else
MsgBox "Invalid option!", vbCritical, "Wrong data"
End If
End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
MsgBox "Data Imported", vbInformation, "Confirmation"
End Sub