title: Wait for big files to open in Excel
body: <p>I've been trying to loop over a bunch of big .csv files in VBA. Each of them is approximately 50MB. At every iteration I open a new CSV to manipulate data but when the .csv is opening there is a downloading message saying that the file is opening and the progress bar always gets stuck at some point while the VBA is waiting for it to finish.</p>
  
  <p>Actually the .csv is opened because if I click "cancel" on the progress bar the code continues running well but I have to do a manual action at every iteration.</p>
  
  <p>My guess is that VBA goes to the next step while the file is not opened or something like that so maybe if I do a Sleep or something like that it could work but what I tried did not work for now. (I already tried Application.EnableEvents = False). Here is my code:</p>
  
  <pre><code>Sub GetOptions()
  
  Application.DisplayAlerts = False
  Application.EnableEvents = False
  
  Set Dates = Sheets("Dates")
  Set Res = Sheets("Options")
  
  Dim dateToday As Date
  
  ETF = "SPY"
  nrows = Dates.Cells(Rows.Count, 1).End(xlUp).Row
  
  
  For i = 708 To nrows
  
      If Dates.Cells(i, 2).Value = "B" Then
          dateToday = Dates.Cells(i, 1).Value
          dateYear = Year(dateToday)
          stringOpening = "P:\Options Database\CSV\" &amp; dateYear &amp; "\bb_" &amp; dateYear &amp; "_" &amp; GetMonth(dateToday) &amp; "\bb_options_" &amp; Format(dateToday, "yyyymmdd") &amp; ".csv"
          Workbooks.Open stringOpening, UpdateLinks:=0, ReadOnly:=True
          Set Options = Workbooks("bb_options_" &amp; Format(dateToday, "yyyymmdd")).Sheets(1)
  
          Do things...
  
          Workbooks("bb_options_" &amp; Format(dateToday, "yyyymmdd")).Close SaveChanges:=False
      End If
  Next i
  
  
  End Sub
  </code></pre>