+ Reply to Thread
Results 1 to 6 of 6

MACRO only copies six files

  1. #1
    Registered User
    Join Date
    06-11-2010
    Location
    Manila
    MS-Off Ver
    Excel 2007
    Posts
    29

    MACRO only copies six files

    Hello,

    I got this code fromm mslynng (the original posts: http://excel.bigresource.com/Track/excel-8Zjqhjv0/) and I have to say I love this code a lot.. problem is that it only seems to copy just six xls files.. I have a 60+ xls files both containing pdf and excel. But the code can ignore the pdf.. i just need the excel. Anyway, I tried to change the code but, obviously, nothing works.. hope your help here.

    Thanks!

    here's the code:

    Please Login or Register  to view this content.
    Last edited by eastydie; 04-14-2011 at 05:31 AM.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: MACRO only copies six files

    Hi eastydie
    The code was stopping when it reached thisworkbook
    try...
    Please Login or Register  to view this content.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Registered User
    Join Date
    06-11-2010
    Location
    Manila
    MS-Off Ver
    Excel 2007
    Posts
    29

    Re: MACRO only copies six files

    Hi, sorry it took me so long.. I got sick yesterday. It's pretty warm here in Manila Got me a free migraine..

    Thanks pike! That made the trick! I'm confused with
    Please Login or Register  to view this content.
    and the
    Please Login or Register  to view this content.
    part. If it is not too trouble, do you mind shedding some light on the two? But it's okay if you are too busy. This is enough for me Thanks again!
    Last edited by eastydie; 04-14-2011 at 05:44 AM. Reason: typo

  4. #4
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: MACRO only copies six files

    Hi eastydie
    Please Login or Register  to view this content.
    are the similar and are use to iterate over all files in a folder
    The difference is if you use the () which means you must use the objects methods/syntax

    The if not statement "this workbook" works opening and copying workbooks ( because the statment is True) untill it loops and selects "this workbook", so the first part of the if statement is now false . Using "Else: Filename = "" is the trigger/default to exit the loop. so its not needed

  5. #5
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: MACRO only copies six files

    Dir is the same as Dir() and can only be used after you have used Dir("some_path") or Dir("") to set up the search (and only until the function returns "" - thereafter you have to specify arguments again).
    The Dir - or Dir() - then simply repeats and returns the next matching file or folder.
    Remember what the dormouse said
    Feed your head

  6. #6
    Registered User
    Join Date
    06-11-2010
    Location
    Manila
    MS-Off Ver
    Excel 2007
    Posts
    29

    Re: MACRO only copies six files

    Thanks pike and romperstomper!

    I did some trial and error yesterday, with the
    Please Login or Register  to view this content.
    placing it within and outside the if else condition to understand it better. Thanks again for taking time in explaining me the code.

+ 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