title: Losing data through csv file opening loop vba
body: <p>I got CSV dataset every day from 5 partners after 8PM. The files are in the same structure, the range of the size 4- 130 KB in the same folder. I want to merge all files to one by macro, the today result is days from 10-15th are missing. Data of 16th (the last day) are good. When I run the macro for only one partner, I get full result. What can be the problem?</p>
  
  <pre><code>Dim MyFolder As String
  Dim MyFile As String
  Dim last As Integer
  Dim newrow As Integer
  Dim sh As Worksheet
  Dim name As String
  Dim name2 As String
  Dim myYear As Variant
  Dim myMonth As Variant
  
  Sheets("Munka1").Select
  name = ActiveWorkbook.name
  
  ScreenUpdating = False
  Range(Cells(2, 1), Cells(300000, 200)).Select
  Selection.Clear
  Cells(2, 1).Select
  
  
  MyFolder = "InputFolder"
  MyFile = Dir(MyFolder &amp; "\FILE_*" &amp; "*.csv")
  
  Do While MyFile &lt;&gt; ""
  Workbooks.Open Filename:=MyFolder &amp; "\" &amp; MyFile, Local:=True
  name2 = ActiveWorkbook.name
  On Error Resume Next
  
  Range(Cells(2, 1), Cells(3000, 11)).Select
  Selection.Copy
  
  Windows(name).Activate
  Cells(newrow, 1).Select
  ActiveSheet.Paste
  
  last= Range("A1", Range("A1").End(xlDown)).Rows.Count
  newrow = last + 1
  
  Application.CutCopyMode = False
  Windows(name2).Close savechanges:=False
  
  MyFile = Dir
  Loop
  </code></pre>