Solved

import multiple text files in directory into excel

Posted on 2013-11-04
13
433 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 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
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 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Missing Rows in Excel Spreadsheet 2 43
How to fix this UDF to handle blank cells? 8 41
Custom fill series 12 30
LOOK FOR 22 23
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

738 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