با سلام
پوشه test را در درایو c کپی کنید و فایل دیگر را خارج از آن پوشه اجرا کنید
کد PHP:
Option Explicit
Public XX As String
Private Sub CommandButton1_Click()
Dim directory As String, fileName As String, sheet As Worksheet, i As Integer, j As Integer
Application.ScreenUpdating = False
XX = ActiveWorkbook.Name
directory = "c:\test\"
fileName = Dir(directory & "*.xl??")
Do While fileName <> ""
i = i + 1
j = 2
Cells(i, 1) = fileName
Workbooks.Open (directory & fileName)
For Each sheet In Workbooks(fileName).Worksheets
Workbooks(XX).Worksheets(1).Cells(i, j).Value = sheet.Name
j = j + 1
Workbooks(XX).Worksheets(1).Cells(i, j).Value = sheet.Range("A1")
j = j + 1
Next sheet
Workbooks(fileName).Close
fileName = Dir()
Loop
Application.ScreenUpdating = True
End Sub
علاقه مندی ها (Bookmarks)