Hi..
Try this.. change the strpath to suit..
Private Sub CommandButton1_Click()
Dim x, w, i As Long, j As Long, jj As Long, cnt As Long, strpath As String
' Set Folder to Search
strpath = "D:\Rank\"
' Put all .xls files found in folder (and subfolders) into an array
x = Split(CreateObject("wscript.shell").exec("cmd /c Dir """ & strpath & "*.xls"" /s/b").stdout.readall, vbCrLf)
ReDim w(1 To UBound(x) * 3)
cnt = 1
' Loop though the array of .xls* files
For i = LBound(x) To UBound(x) - 1
' Open each Workbook and build new array
With GetObject(x(i))
y = .Sheets(1).Range("A1").CurrentRegion.Offset(1).Resize(3)
For j = 1 To 3
For jj = 1 To 3
w(cnt) = Trim(w(cnt) & " " & y(j, jj))
Next jj
cnt = cnt + 1
Next j
.Close
End With
Next i
' Put data into Sheet1 of ThisWorkbook
Sheets("Sheet1").Range("A1").Resize(UBound(x) * 3).Value = Application.Transpose(w)
Sheets("Sheet1").Range("A1").Resize(UBound(x) * 3, 1).TextToColumns DataType:=xlDelimited, Space:=True
End Sub
Bookmarks