Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to Automate Text Import for Multiple Files
I searched and this seemed a topic that came up a lot, but as I'm a
complete newbie at macros I couldn't quite grasp what changes I needed to make in order to adapt a macro such as Pearson's for my use. What I have...a folder with 50 or so files that I currently open one by one with the text import wizard. What I need to do...I need to open each of those files with tab & space delimiters, copy certain contents (always cell C32 to the end of the data in column C), and paste it in a new workbook. Each subsequent set of copied data would be pasted in the next column in the new workbook. I tried recording a macro as I imported one of these files, copied the desired cell range, and pasted it in a new workbook, but that's as far as I got. Here is the code for what I've done so far: Sub Macro2() ' ' Macro2 Macro ' ' ChDir _ "TestDiretory" Workbooks.OpenText Filename:= _ "TestDirectory/TestFile" _ , Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _ xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, Semicolon:=False, _ Comma:=False, Space:=True, Other:=False, FieldInfo:=Array(Array(1, 1), _ Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1)), TrailingMinusNumbers:=True Range("C32").Select Range(Selection, Selection.End(xlDown)).Select Selection.Copy Workbooks.Add ActiveSheet.Paste End Sub Thoughts on what to do next? First, I need it to open all the folders in a given directory and second I need it to paste each copied column of data into the next column over in the new workbook. Thank you greatly for any help you can provide and for having patience with such a novice. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Import multiple text files (Macro) | Excel Discussion (Misc queries) | |||
Import of Multiple Text Files | Excel Programming | |||
Need to import multiple files with a macro | Excel Programming | |||
Import multiple text files into excel | Excel Programming | |||
Import multiple files macro can't find files | Excel Programming |