Sub 查另一文件的全部表名()
On Error Resume Next
Dim i%
Dim SH As Worksheet
Application.ScreenUpdating = False
Workbooks.Open Filename:=ThisWorkbook.Path & "\2.xls"
Windows("1.xls").Activate '当前文件名称
Sheets("Sheet1").Select '当前表名称
i = 1 '将表名称返回到第1行
For Each SH In Workbooks("2.xls").Worksheets
Cells(i, 1) = SH.Name '将表名称返回到第1列
i = i + 1 '返回每个表名称向下移动1行
Next SH
Windows("2.xls").Close '关闭对象文件
Application.ScreenUpdating = True
End Sub
|
|
susan