Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all
I have 2 main questions. I am basically repeating over and over agai the below code for a bunch of different files. I am essentiall creating a new workbook, and then opening up a bunch of files, copyin them, and pasting each one onto a new sheet, so they are all in the ne workbook. The names always stay the same but new files can be added. Worksheets.Add(After:=ActiveSheet).Name = "East" Workbooks.OpenText Filename:= _ "C:\Pen\Data\Worlds\zone_east.lst", _ Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, Space:=True Range(Selection, Selection.End(xlToRight)).Select Range(Selection, Selection.End(xlDown)).Select Selection.Copy Windows(WorkAct).Activate Selection.PasteSpecial Paste:=xlPasteValues Cells.Select Cells.EntireColumn.AutoFit Windows("zone_east.lst").Close Worksheets.Add(After:=ActiveSheet).Name = "West" etc. Now my questions, if all the .lst files are in the directory "Worlds or subfolders of "Worlds" is there a way to find them withou hardcoding all the names into the macro? Also, is there a way to nam the sheet based on the file Name (ie. whatever is after "...zone_"). Essentially, so I don't have to go in and manually add file names an sheets but the macro will automatically detect and name the sheet. Thanks in advance. Ricke -- Message posted from http://www.ExcelForum.com |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I rename files that are related. | Excel Discussion (Misc queries) | |||
Help to rename files | Excel Worksheet Functions | |||
Rename Files from Explorer | Excel Programming | |||
Copy and rename files from hyperlink | Excel Programming | |||
Rename Batch of Files in VBA | Excel Programming |