Hello Everyone,
I cant seem to find what is cauing my error.. I s a simpl code to on a file in the foldercopy a column ofdata nd pase in thedestination file on the next open column.
Can someone help, maybe Ijus need more sleep, becaue I antsee it.
Sub LoopThroughDirectory()
Dim MyFile As String
Dim ecol
Dim Filepath As String
Filepath = "C:\Users\HansoD02\Downloads\Desktop\Suppliers-master"
MyFile = Dir(Filepath)
Do While Len(MyFile) > 0
If MyFile = "zmaster.xlsm" Then
Exit Sub
End If
Workbooks.Open (Filepath & MyFile)
Range("C6:C12").Copy
ActiveWorkbook.Close
ecol = Sheet1.Cells(2, Column.Count).End(xlToRight).Offset(1, 2).Column
ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range(Cells(1, ecol), Cells(1, ecol))
MyFile = Dir
Loop
End Sub
I cant seem to find what is cauing my error.. I s a simpl code to on a file in the foldercopy a column ofdata nd pase in thedestination file on the next open column.
Can someone help, maybe Ijus need more sleep, becaue I antsee it.
Sub LoopThroughDirectory()
Dim MyFile As String
Dim ecol
Dim Filepath As String
Filepath = "C:\Users\HansoD02\Downloads\Desktop\Suppliers-master"
MyFile = Dir(Filepath)
Do While Len(MyFile) > 0
If MyFile = "zmaster.xlsm" Then
Exit Sub
End If
Workbooks.Open (Filepath & MyFile)
Range("C6:C12").Copy
ActiveWorkbook.Close
ecol = Sheet1.Cells(2, Column.Count).End(xlToRight).Offset(1, 2).Column
ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range(Cells(1, ecol), Cells(1, ecol))
MyFile = Dir
Loop
End Sub