试试这个:
Sub tgr()
Dim wsDest As Worksheet
Dim oShell As Object
Dim strFolderPath As String
Dim strFileName As String
Dim strMonthYear As String
Set oShell = CreateObject("Shell.Application")
On Error Resume Next
strFolderPath = oShell.BrowseForFolder(0, "Select Folder", 0).Self.Path & Application.PathSeparator
Set oShell = Nothing
On Error GoTo 0
If Len(strFolderPath) = 0 Then Exit Sub 'Pressed cancel
Application.ScreenUpdating = False
Set wsDest = Sheets.Add(After:=Sheets(Sheets.Count))
wsDest.Range("A1").Value = "Month Year"
strFileName = Dir(strFolderPath & "*.xls*")
Do While Len(strFileName) > 0
With Workbooks.Open(strFolderPath & strFileName)
.Sheets(1).UsedRange.Copy wsDest.Cells(Rows.Count, "B").End(xlUp).Offset(1)
.Close False
End With
strMonthYear = WorksheetFunction.Trim(Right(Replace(strFileName, " ", String(99, " ")), 198))
wsDest.Range(wsDest.Cells(Rows.Count, "A").End(xlUp).Offset(1), wsDest.Cells(Rows.Count, "B").End(xlUp).Offset(, -1)).Value = strMonthYear
strFileName = Dir
Loop
Application.ScreenUpdating = True
Set wsDest = Nothing
End Sub