Hi,
I tried running the code but it does not append the data. It does not give me any error
. This is what I have in the Master excel sheet
[TABLE="width: 256"]
<colgroup><col width="64" span="4" style="width:48pt"> </colgroup><tbody>[TR]
[TD="width: 64"]Test A[/TD]
[TD="width: 64"]Test B[/TD]
[TD="width: 64"]Test C[/TD]
[TD="width: 64"]Test D[/TD]
[/TR]
[TR]
[TD="class: xl63"]1[/TD]
[TD="class: xl63"]2[/TD]
[TD="class: xl63"]3[/TD]
[TD="class: xl63"]4[/TD]
[/TR]
[TR]
[TD="class: xl63"]2[/TD]
[TD="class: xl63"]3[/TD]
[TD="class: xl63"]4[/TD]
[TD="class: xl63"]1[/TD]
[/TR]
[TR]
[TD="class: xl63"]RP[/TD]
[TD="class: xl63"]RP[/TD]
[TD="class: xl63"]RP[/TD]
[TD="class: xl63"]4[/TD]
[/TR]
[TR]
[TD="class: xl63"]RP[/TD]
[TD="class: xl63"]RP[/TD]
[TD="class: xl63"]RP[/TD]
[TD="class: xl63"]4[/TD]
[/TR]
</tbody>[/TABLE]
This is what is present in the User 1 and User 2 excel workbooks
User 1
[TABLE="width: 256"]
<colgroup><col width="64" span="4" style="width:48pt"> </colgroup><tbody>[TR]
[TD="width: 64"]Test A[/TD]
[TD="width: 64"]Test B[/TD]
[TD="width: 64"]Test C[/TD]
[TD="width: 64"]Test D[/TD]
[/TR]
[TR]
[TD="class: xl63"]1[/TD]
[TD="class: xl63"]2[/TD]
[TD="class: xl63"]3[/TD]
[TD="class: xl63"]4[/TD]
[/TR]
[TR]
[TD="class: xl63"]1[/TD]
[TD="class: xl63"]2[/TD]
[TD="class: xl63"]3[/TD]
[TD="class: xl63"]4[/TD]
[/TR]
[TR]
[TD="class: xl63"]1[/TD]
[TD="class: xl63"]2[/TD]
[TD="class: xl63"]3[/TD]
[TD="class: xl63"]4[/TD]
[/TR]
[TR]
[TD="class: xl63"]1[/TD]
[TD="class: xl63"]2[/TD]
[TD="class: xl63"]3[/TD]
[TD="class: xl63"]4[/TD]
[/TR]
</tbody>[/TABLE]
User 2
[TABLE="width: 256"]
<colgroup><col width="64" span="4" style="width:48pt"> </colgroup><tbody>[TR]
[TD="width: 64"]Test A[/TD]
[TD="width: 64"]Test B[/TD]
[TD="width: 64"]Test C[/TD]
[TD="width: 64"]Test D[/TD]
[/TR]
[TR]
[TD="class: xl63"]4[/TD]
[TD="class: xl63"]2[/TD]
[TD="class: xl63"]3[/TD]
[TD="class: xl63"]1[/TD]
[/TR]
[TR]
[TD="class: xl63"]4[/TD]
[TD="class: xl63"]2[/TD]
[TD="class: xl63"]3[/TD]
[TD="class: xl63"]1[/TD]
[/TR]
[TR]
[TD="class: xl63"]4[/TD]
[TD="class: xl63"]2[/TD]
[TD="class: xl63"]3[/TD]
[TD="class: xl63"]1[/TD]
[/TR]
[TR]
[TD="class: xl63"]4[/TD]
[TD="class: xl63"]2[/TD]
[TD="class: xl63"]3[/TD]
[TD="class: xl63"]1[/TD]
[/TR]
</tbody>[/TABLE]
Here is my slightly modified code
Sub LoopThroughFiles()
Dim StrFile As String
Dim Filepath As String
Dim TempFile As Workbook
Dim MasterFile As String
StrFile = Dir("C:\\Users\\Desktop\\Test\\**")
Filepath = "C:\Users\Desktop\Test"
MasterFile = "C:\Users\Desktop\Test\Main.xlsm"
Workbooks.Open Filename:=MasterFile
Set MstFile = ActiveWorkbook
MLR = MstFile.Sheets("Hopper").Cells(Rows.Count, "A").End(xlUp).Row
Workbooks.Open Filename:=Filepath & StrFile
Set TempFile = ActiveWorkbook
LR = TempFile.Sheets("Main").Cells(Rows.Count, "A").End(xlUp).Row
TempFile.Sheets("Main").Range("A2:D" & LR).Copy
MstFile.Sheets("Hopper").Cells(MLR + 1, 1).PasteSpecial
Do While Len(StrFile) > 0
StrFile = Dir()
If Len(StrFile) = 0 Then
Exit Do
End If
Workbooks.Open Filename:=Filepath & StrFile
Set TempFile = ActiveWorkbook
LR = TempFile.Sheets("Main").Cells(Rows.Count, "A").End(xlUp).Row
MLR = MstFile.Sheets("Hopper").Cells(Rows.Count, "A").End(xlUp).Row
TempFile.Sheets("Main").Range("A2:D" & LR).Copy
MstFile.Sheets("Hopper").Cells(MLR + 1, 1).PasteSpecial
Loop
End Sub
Thanks,