Solved

import multiple text files in directory into excel

Posted on 2013-11-04
13
413 Views
Last Modified: 2013-11-06
hi,

need help in importing in between 25 to 1000 text files in one directory into the MS Excel. attached example of text file and excel output with some code in module(Alt F11). the structure of the text file are always same. I need some assistance in expanding the code into reading multiple text file and split row number 7 onward into separated column, see attached ( column G onward need to be separated into individual column.

thanking you
26HL
E01-lb1-13-2.txt
import-To-Excel.xls
0
Comment
Question by:26lh
  • 6
  • 4
  • 3
13 Comments
 
LVL 29

Expert Comment

by:gowflow
ID: 39621663
Hi
Let me get what you want correctly:

1) Do you want to select specific files in a certain directory and then when you click ok you want to import each and everyone of the files selected in the format you attached in the excel each file in 1 row all following each others.

or

2) Do you want to select a specific directory and then it would import ALL the files in that directory in the format you attached in the excel each file in 1 row all following each others.


pls advise
gowflow
0
 
LVL 12

Expert Comment

by:Harry Lee
ID: 39622544
26lh,

Try the macro ImportAllTXT to see if this is what you want.
Import-All-TXT-in-Folder.xlsm
0
 

Author Comment

by:26lh
ID: 39623934
Hi Gowflow, thanks for the prompt response.

I would like to import all of the text file (example attached) from selected directory into excel as per attached example ( new attached excel file ). separated column G onward into separate column for date and value.

thanking you
import-To-Excel.xls
E01-lb1-13-2.txt
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 29

Expert Comment

by:gowflow
ID: 39623937
Hi 26lh

Despite you not answering my first querry, I have built the file to work in all possible situations.

Check out this file and here is how it works:

You can choose a folder to import and it will import all the text files 'AFTER' the last existing row in the current worksheet. You may also have the option to import selected files in any directory. To do this select the corresponding option when asked (choose [NO]) and when the open dialog show you all the text files then you may select 1 file all the files or simply select any file and press CTRL to select other files if you want the files selected not to follow)

After pressing ok the routine will import each file in one row all after the last existing row on your worksheet.

Please let me know your comments.
Rgds/gowflow
import-To-Excel.xls
0
 

Author Comment

by:26lh
ID: 39623940
Hi Gowflow,

if there are 25 text files in a directory, there should be 25 rows of record in excel. one row in excel for 1 imported text file.

thanking you

26LH
0
 
LVL 29

Expert Comment

by:gowflow
ID: 39623959
Have you chcked the solution I just posted ? our replied crossed. !!!
gowflow
0
 

Author Comment

by:26lh
ID: 39623974
Hi Gowflow, thanks

good, but you have not separated row 7 onward of the text file into 2 separated columns for date and value see attached excel file Posted on 2013-11-05 at 21:37:32 ID: 39623934.


thanking you

26LH
0
 
LVL 29

Assisted Solution

by:gowflow
gowflow earned 250 total points
ID: 39624098
I took back the same code you had and thought it was ok.
I see you want the precipitations to be separated.

Is that what you want  ??? pls check it out.
gowflow
import-To-Excel.xls
0
 
LVL 12

Accepted Solution

by:
Harry Lee earned 250 total points
ID: 39625461
26lh,

I think this is what you want. Can you check the macro?
Import-All-TXT-in-Folder.xlsm
0
 
LVL 29

Expert Comment

by:gowflow
ID: 39625779
Did you check the solution I posted in ID: 39624098
gowflow
0
 

Author Closing Comment

by:26lh
ID: 39626943
Hi goflow and HarryHYLee. thank you both for producing excellent results as required and more. I think it is fair to award both of you with 250 points each as both of you produced the best solution in a different way, unfortunately the system is not allowed for me to pick both of you that has produced best solution, so it's automatically picked one of you not me. once again thank you both.

26lh
0
 
LVL 29

Expert Comment

by:gowflow
ID: 39627041
tks your comments and appreciation glad we could help.
gowflow
0
 
LVL 12

Expert Comment

by:Harry Lee
ID: 39628002
I'm glad I can help.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question