hi ,
i have written the below code by reading some threads on Mr Excel .
I am trying to transfer data from Multiple workbooks into a master excel workbook automatically using VBA.
i have saved my excel sheets (.xlsb) in a folder and also a Master Sheet with name of Collated C:\Users\HP\Desktop\UPD
All the sheets are saved by name of upd05122017, upd06122017. i have also input a code in This Workbook so when i opened the master file , all the data is being captured .
below is the code , please help
Sub LoopThroughDirectory()
Dim MyFile As String
Dim erow
MyFile = Dir("C:\Users\HP\Desktop\UPD")
Do While Len(MyFile) > 0
If MyFile = "Collated.xlsm" Then
Exit Sub
End If
Workbooks.Open (MyFile)
Range("A2:S5000").Copy
ActiveWorkbook.Close
erow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Paste Destination:=Worksheets("Raw").Range(Cells(erow, 1), Cells(erow, 19))
MyFile = Dir
Loop
End Sub
i have written the below code by reading some threads on Mr Excel .
I am trying to transfer data from Multiple workbooks into a master excel workbook automatically using VBA.
i have saved my excel sheets (.xlsb) in a folder and also a Master Sheet with name of Collated C:\Users\HP\Desktop\UPD
All the sheets are saved by name of upd05122017, upd06122017. i have also input a code in This Workbook so when i opened the master file , all the data is being captured .
below is the code , please help
Sub LoopThroughDirectory()
Dim MyFile As String
Dim erow
MyFile = Dir("C:\Users\HP\Desktop\UPD")
Do While Len(MyFile) > 0
If MyFile = "Collated.xlsm" Then
Exit Sub
End If
Workbooks.Open (MyFile)
Range("A2:S5000").Copy
ActiveWorkbook.Close
erow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Paste Destination:=Worksheets("Raw").Range(Cells(erow, 1), Cells(erow, 19))
MyFile = Dir
Loop
End Sub