?
Solved

import multiple text files in directory into excel

Posted on 2013-11-04
13
Medium Priority
?
446 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 3
13 Comments
 
LVL 31

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 31

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 31

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 31

Assisted Solution

by:gowflow
gowflow earned 1000 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 1000 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 31

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 31

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
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…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

764 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