I am using the following VBA code to import a rather large text file into a spreadsheet, however this seems to take ages. (Approximately 0.0064 seconds per cell, which quickly becomes too much when the files are substantially larger.) The file is simply stored locally so this could not be an issue.
My code currently looks like this:
Public Sub DataImport(fullFileName As String, worksheetName As String, cellName As String)
'Move to the sheet and desired first cell
ActiveWorkbook.Sheets(worksheetName).Activate
Range(cellName).Activate
Open fullFileName For Input As #1
' Copy the file into the excel sheet
row_number = 0
Do Until EOF(1)
Line Input #1, LineFromFile
LineItems = Split(LineFromFile, vbTab)
For i1 = LBound(LineItems) To UBound(LineItems)
ActiveCell.Offset(row_number, i1).Value = LineItems(i1)
On Error Resume Next
ActiveCell.Offset(row_number, i1).Value = ActiveCell.Offset(row_number, i1).Value * 1
Next i1
row_number = row_number + 1
Loop
Close #1
End Sub
EDIT: I am working on Office For Mac and the final product should work on both Windows and OS X.
All help on this is greatly appreciated!
Kind regards