You are on page 1of 1

Sub LoopThroughDirectory()

Dim MyFile As String


Dim erow
Dim Filepath As String
Filepath = "C:\Test\"
MyFile = Dir(Filepath)
Do While Len(MyFile) > 0
If MyFile = "Plan1.xlsm" Then
Exit Sub
End If
Workbooks.Open (Filepath & MyFile)
Range("B3:B4:B5:D5").Copy
ActiveWorkbook.Close
erow = Plan1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Paste Destination:=Worksheets("Plan1").Range(Cells(erow, 1), Cel
ls(erow, 4))
MyFile = Dir
Loop
End Sub

You might also like