Please take a look at the attachments. I would like to import the .csv file into excel using VBA and have written the code. It is not working exactly as planned.
Ultimately I would like to have the ID in column A, Last name in B and First name in C.
Currently, my ID and First Name is combined in Column A which is not what I want. Also it doesn't seem to loop.
Thanks!
Sub importingtextfile()
Dim Filepath As String
Filepath = "C:\Users\dchao\Desktop\VBA Test\authors.csv"
Open Filepath For Input As #1
ActiveSheet.Cells(1, 1).Select
row_number = 0
Do Until EOF(1)
Line Input #1, LineFromFile
lineitems = Split(LineFromFile, ",")
ActiveCell.Offset(row_number, 0).Value = lineitems(2)
ActiveCell.Offset(row_number, 1).Value = lineitems(1)
ActiveCell.Offset(row_number, 2).Value = lineitems(0)
row_number = row_number + 1
Loop
Close #1
End Sub
authors.csv
vbatestfile.xlsm
Bookmarks