excel vba - using delimiter as column format for impoted txt files -


how can apply delimiter "^" columns imported multiple txt files. pls help. ..

private sub commandbutton1_click()   application.screenupdating = false  dim ofiledialog filedialog dim loopfolderpath string dim ofilesystem filesystemobject dim oloopfolder folder dim ofilepath file dim ofile textstream dim rown long dim coln long dim ianswer integer on error goto error_handler  set ofiledialog = application.filedialog(msofiledialogfolderpicker)  rown = 1 coln = 1  ofiledialog if .show     activesheet.columns(coln).cells.clear      loopfolderpath = .selecteditems(1) & "\"      set ofilesystem = createobject("scripting.filesystemobject")     set oloopfolder = ofilesystem.getfolder(loopfolderpath)      each ofilepath in oloopfolder.files         set ofile = ofilesystem.opentextfile(ofilepath)          ofile              until .atendofstream                 activesheet.cells(rown, coln).value = .readline                  loopfolderpath = space(1)                 rown = rown + 1                  loop              .close         end     next ofilepath end if ianswer = msgbox("your textfiles have been inputted.", vbinformation) end  exit_sub: set ofilepath = nothing set oloopfolder = nothing set ofilesystem = nothing set ofiledialog = nothing  application.screenupdating = true  exit sub  error_handler:     ' code error handling     err.clear     goto exit_sub  end sub 

activesheet.range("x:x").texttocolumns destination:=range("x#"), datatype:=xldelimited, _     textqualifier:=xldoublequote, other:=true, otherchar:="^" 

of course need replace x:x proper column , x# proper range.

it took 30 seconds using macro recorder code.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -