Quote Originally Posted by jindon View Post
I don't know what you are trying to do, but
1) What is FXArr ?
2) FNum in red is obviously out of range.
Sorry i didnt mention my points clearly, but really thanks for your reply!!

I want to copy data form a folder of excel files, then pasting those data into the excel file I assigned. The problem is that every time the program copies data from those files, it will replace the data from the last file. So, at last, it only shows the last file's data. I just want to know, how can I paste all data in the excel file? And what should i amend?

I used this codes for copying and pasting:

If FNum > 0 Then
    For FNum = LBound(MyFiles) To UBound(MyFiles)
            
    Set mybook = Nothing
                On Error Resume Next
                Set mybook = Workbooks.Open(FilePath & MyFiles(FNum))
                On Error GoTo 0
    
    Sheets("FX Historical Data").Activate
    RowCount = Range("A1").End(xlDown).Row
    FXArr = Range(Range("A2"), Range("b2").Offset(RowCount - 1))
    
    Sheets("Position Data").Activate
    RowCount = Range("A1").End(xlDown).Row
    PositionArr = Range(Range("A2"), Range("d2").Offset(RowCount - 1))
    
    ActiveWorkbook.Close

Next FNum
End If
    
    Sheets("FX Historical Data").Activate
    Range(Range("A2"), Range("b2").Offset(UBound(FXArr, 1) - 1)) = FXArr
    
    Sheets("Position Data").Activate
    Range(Range("A2"), Range("d2").Offset(UBound(PositionArr, 1) - 1)) = PositionArr
   
    
    Sheets("Report").Activate
    
    Application.ScreenUpdating = True
    Application.Calculation = xlCalculationAutomatic
End Sub