Copy/Paste Data from Multiple Text Files into Excel File

jdaywalt

Board Regular
Joined
Jul 18, 2012
Messages
63
OK, let's see if I can explain this. I have a folder that contains 6-7 files that are saved with a ".xls" extension, but they are actually text files. I want to write a macro that when executed, first prompts the user to choose the appropriate folder that contains the files. Once they've done this, I want the macro to open the first file, convert to a ".xls" file (it is tab delimited), then copy/paste the data from that file into another workbook. I then want it to close the first file without saving, open the second file, convert to .xls, copy/paste the data directly below data from the first file. This process is repeated for all files in the selected folder.

When I recorded a macro to do the conversion from "text" to ".xls", here is the basic code it returned, if that helps in understanding the layout of the text files:

Workbooks.OpenText Filename:="The file name I chose", Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1)), TrailingMinusNumbers:=True

Can someone help?
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Forum statistics

Threads
1,223,237
Messages
6,170,928
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top