title: Vbscript to import csv into excel
body: <p>I would like to make a VBSript that will open a csv of varying rows and columns and paste them starting at row 4 column 1. So far what I have written is slow and has the amount of columns hard coded into it.</p>
  
  <pre><code>Set objExcel = CreateObject("Excel.Application")
  Set objWorkbook = objExcel.Workbooks.Open(wscript.Arguments(0))
  objExcel.Visible = True
  objExcel.Cells(1, 4).Value = wscript.Arguments(1)+" - "+wscript.Arguments(2)
  objExcel.Cells(2, 4).Value = wscript.Arguments(3)
  
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objTextFile = objFSO.OpenTextFile (wscript.Arguments(4))
  cCount = 1
  rCount = 4
  
  Do While objTextFile.AtEndOfStream &lt;&gt; True
          arrUserRecord = split(objTextFile.Readline, ",")
          Do While cCount&lt;213
              objExcel.Cells(rCount, cCount).Value = arrUserRecord(cCount-1)
              cCount=cCount+1
          Loop
          cCount=1
          rCount=1+rCount
  Loop
  </code></pre>