Solved

import multiple text files in directory into excel

Posted on 2013-11-04
13
406 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
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 view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now