+ Reply to Thread
Results 1 to 6 of 6

Loop in different files

  1. #1
    Registered User
    Join Date
    08-07-2013
    Location
    Saudi Arabia
    MS-Off Ver
    Excel 2007 - 2010
    Posts
    73

    Loop in different files

    Helo guys,

    I want to run a Loop in different files. Right now the code I have, it erase all those sheets that doesnt countain "Resp. Co" inside of a cell, but only in the file called "MorningReport.xls". I need to do the same macro but from the file "20130101" to the file "20130131". As you can see, the files contain the yearmonthday so it can be continuous, so I was thinking that maybe I can run a file name as numbers.

    I tried this one but is not working:

    Please Login or Register  to view this content.
    Can you help me please?! thanks!!
    Last edited by jnh0; 09-02-2013 at 01:39 AM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Perhaps.

    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    08-07-2013
    Location
    Saudi Arabia
    MS-Off Ver
    Excel 2007 - 2010
    Posts
    73

    Re: Loop in different files

    It gives an error in this line:

    Please Login or Register  to view this content.
    Sorry, I dont know if I was quite clear in the name of the files. The files names are 20130101.xls to 20130131.xls
    Last edited by jnh0; 09-01-2013 at 10:06 AM.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    An error?

    Any particular error?

    If the problem is the file extension:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-07-2013
    Location
    Saudi Arabia
    MS-Off Ver
    Excel 2007 - 2010
    Posts
    73

    Re: Loop in different files

    No, just subscript out of range! :S

  6. #6
    Registered User
    Join Date
    08-07-2013
    Location
    Saudi Arabia
    MS-Off Ver
    Excel 2007 - 2010
    Posts
    73

    Re: Loop in different files

    Hey I found where was the error. The date

    Please Login or Register  to view this content.
    The 31 was in the middle instead that being at the last. I tried it that way and it worked.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 5
    Last Post: 11-19-2013, 04:11 PM
  2. Loop between 2 files in a folder
    By jharaldson in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-14-2013, 02:33 AM
  3. Replies: 0
    Last Post: 03-13-2013, 09:08 PM
  4. [SOLVED] Need to use a loop to update my files.
    By kjsconv in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-29-2013, 02:04 PM
  5. Loop through files?
    By MP3265 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-28-2013, 05:01 PM

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