Solved

import multiple text files in directory into excel

Posted on 2013-11-04
13
396 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

705 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