I tried searching for answer for a couple days, cannot find one. Maybe you guys can help.
I am trying to load data from an .txt file, split the columns, and paste the data into excel using vba. I managed piece together a macro, but pasting the data line by line is very slow. How can I speed up this process?
*Only the relevant code is posted below
Bonus points if you can delete the first row in the loaded .txt file.
Dim MyData As String
FilePath = *Folder Location*
Open FilePath For Binary As #1
MyData = Space$(LOF(1))
Get #1 , , MyData
Close #1
i=1
For Each Row In VBA.Split(MyData, vbCrLf)
Next col
Next Row
I am trying to load data from an .txt file, split the columns, and paste the data into excel using vba. I managed piece together a macro, but pasting the data line by line is very slow. How can I speed up this process?
*Only the relevant code is posted below
Bonus points if you can delete the first row in the loaded .txt file.
Dim MyData As String
FilePath = *Folder Location*
Open FilePath For Binary As #1
MyData = Space$(LOF(1))
Get #1 , , MyData
Close #1
i=1
For Each Row In VBA.Split(MyData, vbCrLf)
j = 1
Selection.Offset(1, 0).Select
Selection.Offset(1, 0).Select
For Each col In VBA.Split(Row, vbTab)
ActiveCell.Offset(i - 1, j - 1).Value = col
j = j + 1
ActiveCell.Offset(i - 1, j - 1).Value = col
j = j + 1
Next col
Next Row