samotné načtení a zápis dat trvá u mně cca 2 s, zbytek času si bere excel na doplnění vzorců, kalkulace atd
Sub subImportCSV()
Dim sFileTemp As String
sFileTemp = Dir(ThisWorkbook.Path & "\*.csv")
Dim sFile As String, dFileTime As Date
While Not sFileTemp = vbNullString
If FileDateTime(ThisWorkbook.Path & "\" & sFileTemp) > dFileTime Then
sFile = ThisWorkbook.Path & "\" & sFileTemp
End If
sFileTemp = Dir
Wend
If Not sFile = vbNullString Then
Dim sText As String
With CreateObject("Scripting.FileSystemObject").OpenTextFile(sFile)
sText = .ReadAll
.Close
End With 'CreateObject("Scripting.FileSystemObject").OpenTextFile(sFile)
Dim iRows As Long
iRows = (Len(sText) - Len(Replace(sText, vbCrLf, vbNullString))) / 2
With CreateObject("Scripting.FileSystemObject").OpenTextFile(sFile)
Dim vValues() As Variant
ReDim vValues(iRows, UBound(Split(.ReadLine, ";"))) 'záhlaví
Dim iRow As Long, iColumn As Long
iRow = -1
Dim sLine As String
While Not .AtEndOfStream
iRow = iRow + 1
sLine = .ReadLine
For iColumn = 0 To UBound(vValues, 2)
vValues(iRow, iColumn) = Split(sLine, ";")(iColumn)
Next iColumn
Wend
.Close
End With 'CreateObject("Scripting.FileSystemObject").OpenTextFile(sFile)
With ActiveSheet.ListObjects("DataTab").DataBodyRange
If .Rows.Count > 1 Then
.Offset(1, 0).EntireRow.Delete
End If
.Cells(1).Resize(UBound(vValues, 1) + 1, UBound(vValues, 2) + 1).Value = vValues
End With 'ActiveSheet.ListObjects("DataTab").DataBodyRange
Else
MsgBox ("Neexistuje žiadny .csv súbor.")
End If
End Subcitovat