LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Import and Rename Files

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I rename files that are related. FinnSchH2 Excel Discussion (Misc queries) 2 August 31st 07 02:12 PM
Help to rename files Hilton Excel Worksheet Functions 7 July 7th 07 03:51 AM
Rename Files from Explorer BENNY Excel Programming 2 June 19th 04 07:22 PM
Copy and rename files from hyperlink Andy Weller Excel Programming 1 February 12th 04 03:51 PM
Rename Batch of Files in VBA Darren Hill[_2_] Excel Programming 10 December 4th 03 08:31 AM


All times are GMT +1. The time now is 12:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"