+ Reply to Thread
Results 1 to 4 of 4

stepping thru XL files

  1. #1
    Registered User
    Join Date
    11-04-2008
    Location
    USA
    Posts
    29

    stepping thru XL files

    Hello,

    Could anyone suggest a solution to the following:

    I have a long list of .xls files in one folder. I have to open each file, copy a few columns of data and paste it into a single xls file. In my macro I use the following routine to step thru the files:
    Please Login or Register  to view this content.
    Within the loop I need to open each file and copy data which is then pasted into a new file. How would I open each individual file without referencing to it by its exact name ? something like "open *.xls" with the aim that the loop will step thru all the xls files in the folder.

    Thanks for any suggestions !
    Last edited by Leith Ross; 01-14-2009 at 04:27 PM. Reason: Added Code Tags

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello sydmil,

    To make your posts easier to read and copy, please wrap your code. I did it for you this time. Here is how you can do it next time.

    How to wrap your Code
    On the Message window Toolbar you will see the # icon. This will automatically wrap the text you selected with the proper Code tags to create a Code Window in your post.

    You can do this manually by placing the tag [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] at the end.

    Please take so time to familiarize yourself with the Do's and Don'ts here in the Forum, just click on the link below...

    Forum Rules

    Sincerely,
    Leith Ross

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello sydmil,

    This macro should get you going. This is set to copy the range "A2:C35" from "Sheet1" of the source workbook, to "Ax" on "Sheet1" of the workbook the macro is in. "Ax" starts at cell "A2" and goes down.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  4. #4
    Registered User
    Join Date
    11-04-2008
    Location
    USA
    Posts
    29
    Leith,

    thank you for your response and sorry for taking so long to get back.

    I am getting the following error on this line:
    LastRow = .Cells(Rows.Count, .Column).End(xlUp).Row


    "Error 1004: Application-defiend or object defined error."

    Any idea what is causing that ?

    Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1