Code Snippet
Dim xlApp As Excel.Application
Dim scrFSO As Scripting.FileSystemObject
Dim scrTxt As Scripting.TextStream
Dim wbData As Workbook
Dim wsData As Worksheet
Dim wbResult As Workbook
Dim wsResult As Worksheet
Sub Main()
Dim strFN As String
Dim rwData As Long
Dim clData As Long
Dim strLine As String
Dim arrLine As Variant
' initialise key objects
Set xlApp = Excel.Application
Set scrFSO = New Scripting.FileSystemObject
' get the name of the cSV file
strFN = xlApp.GetOpenFilename(filefilter:="CSV File (*.csv), *.csv")
' did the user cancel?
If strFN = "False" Then Exit Sub
' open the csv file
Set scrTxt = scrFSO.OpenTextFile(Filename:=strFN, IOMode:=ForReading)
' create a workbook for the data
Set wbData = xlApp.Workbooks.Add(xlWBATWorksheet)
Set wsData = wbData.Sheets(1)
' create a workbook for the results (or whatever you want)
Set wbResult = xlApp.Workbooks.Add(xlWBATWorksheet)
Set wsResult = wbResult.Sheets(1)
' now work through the csv
Do While Not scrTxt.AtEndOfStream
' make sure the data worksheet is clear
wsData.Cells.Clear
rwData = 0
' loop through the data
Do
' read the data
strLine = scrTxt.ReadLine
arrLine = Split(strLine, ",")
' store it in the data worksheet
rwData = rwData + 1
For clData = 0 To UBound(arrLine)
wsData.Cells(rwData, clData + 1) = arrLine(clData)
Next clData
' test for end of data - your code
' If <end of data set> Then Exit Do
Loop
' now process the data - your code
' writing the results to wsResults (if you want)
Loop
' OK finished - tidy up
scrTxt.Close
wbData.Close savechanges:=False
MsgBox "Finished"
' leaves the results workbook open for the user to save
End Sub