title: Excel VBA - How to read csv file line by line but not the whole file
body: <p>This is my csv file content that I need to read:</p>
  
  <pre><code>"header", "header", "header", "header", "header", "header"
  "value", "value", "", "value", "value", ""
  "value", "value", "value", "value", "value", ""    
  </code></pre>
  
  <p>I found on internet the code to import file:</p>
  
  <pre><code>Sub ImportCSVFile(ByVal filePath As String, ByVal ImportToRow As Integer, ByVal StartColumn As Integer)
  
  Dim line As String
  Dim arrayOfElements
  Dim element As Variant
  
  
  Open filePath For Input As #1 ' Open file for input
      Do While Not EOF(1) ' Loop until end of file
          ImportToRow = ImportToRow + 1
          Line Input #1, line
          arrayOfElements = Split(line, ";") 'Split the line into the array.
  
          'Loop thorugh every element in the array and print to Excelfile
          For Each element In arrayOfElements
              Cells(ImportToRow, StartColumn).Value = element
              StartColumn = StartColumn + 1
          Next
      Loop
  Close #1 ' Close file.
  End Sub
  </code></pre>
  
  <p>For some reason that I haven't figured out, that code doesn't read line by line but the whole file at this line</p>
  
  <pre><code>    Line Input #1, line
  </code></pre>
  
  <p>Can anybody explain why it doesn't work?</p>