excel - Reading data from text file and delimiting -
i have excel 2010 spreadsheet, , reading in information .txt file (and .xls file in future).
this text file has 3 elements per row; firtname, surname , job title, , each element separated comma. have data reading , pasting excel, each row pasted 1 cell. looking paste each element different columns. know should try , delimit, can't figure out syntax.
my question how separate each element , paste it's own cell? use commas separate each element on .txt file, future files might use tabs, full-stops, semi-colons etc. how extend bases covered?
below code, , under code sample of dummy data
sub fetchdatafromtextfile() dim long dim linetext string open "c:\mytxtfile.txt" input #24 = 2 while not eof(24) line input #24, linetext activesheet.cells(i, 2).value = linetext p = split(record, ",") = + 1 wend close #24 end sub
john, doe, boss
johnny, steele, manager
jane, smith, employee
note: competant in other programming languages, not done vb in 6 or 7 years. can never seem wrap head around vb syntax, please treat me novice this.
sub fetchdatafromtextfile() dim long dim linetext string open "c:\mytxtfile.txt" input #24 = 2 while not eof(24) line input #24, linetext dim arr arr = split(cstr(linetext), ", ") j = 1 activesheet.cells(i, j).value = arr(j - 1) next j = + 1 wend close #24 end sub
Comments
Post a Comment