[RESOLVED] importing data from a txt file
newbie -- thanks for your help and your patience -- have a spreadsheet -- now i am importing 12 txt files of data -- 5 lines of header -- 100 rows X 6 columns of numbers -- saved as tab delimited -- i use txt import functions of xcel -- would like to automate the process -- select a file from a pop down menu and import the entire file immediately -- can get to the file (File = Application.GetOpenFilename())
but don't see how to accomplish the import --
many thanks
Re: importing data from a txt file
Re: importing data from a txt file
thanks for your reply --
yes -- from an xcel worksheet -- i'd like to click a button -- browse to the txt file -- select -- open -- and have it read in --
the complete file starting in cell A1 of the worksheet --
if you can point me to a document / book / etc -- i'd be glad to do the legwork -- just don't know where to start --
haven't had much luck blindly searching -- perhaps because i really don't know exactly what i am looking for --
Re: importing data from a txt file
Based on your response I've moved your thread here where VBA is used rather than VB6.
Re: importing data from a txt file
You can use the OpenText function passing the tab delimiter argument...
Code:
Dim sFile As String
sFile = Application.GetOpenFilename("Tab Delimited Text Files (*.txt),*.txt", 1, "Select Tab Delimited Text File...")
If Len(sFile) <> 0 Then
Application.Workbooks.OpenText Filename:=sFile, Origin:=xlMSDOS, DataType:=xlDelimited, Tab:=True
End If
Re: importing data from a txt file
robdog888 -- many thanks -- worked like a charm -- now i need to figure out how to insert the txt file into the existing worksheet at a specific cell -- let me work on that a while and then i'll holler for help in another thread --