I have got this code, but when I run it it does not work. The problem can be I use Fixed width, when I import the file
Gives error on
wrarr = Split(rearr(rec), delim)
All I need is to import the file to where I need it.
Sub ReadTxtFile()
Dim ws As Worksheet
Dim rearr(), wrarr()
Dim fName As String
Dim rowno As Long, colno As Long, rec As Long
Dim cnt As Long, cnt2 As Long
Dim delim As String
Set ws = Worksheets("UnixO")
fName = "C:\Do_It\test\UnixO Tapes.txt"
delim = ","
ifnum = FreeFile
rowno = 1 'row 1
colno = 1 'col A
With ws
Open fName For Input Access Read As #ifnum
rec = 0
Do While Not EOF(ifnum)
Line Input #ifnum, tmpvar
rec = rec + 1
ReDim Preserve rearr(1 To rec)
rearr(rec) = tmpvar
wrarr = Split(rearr(rec), delim)
cnt2 = UBound(wrarr)
For cnt = 0 To cnt2
ws.Cells(rowno, colno + cnt) = wrarr(cnt)
Next cnt
rowno = rowno + 1
Loop
Close #ifnum
End With
End Sub
I do have cross links for this.
https://www.mrexcel.com/forum/excel-...ml#post4870883
http://www.ozgrid.com/forum/showthre...goto=newpost**
https://www.excelguru.ca/forums/show...rt-of-txt-file
Bookmarks