+ Reply to Thread
Results 1 to 6 of 6

VBA not cycling through and processing all files in folder

  1. #1
    Forum Contributor
    Join Date
    05-04-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    125

    VBA not cycling through and processing all files in folder

    Hi all,

    I've been working on some code with the help of a fellow board member to cycle through csv files in a folder and modify the date format from DD/MM/YYYY to YYYY-MM-DD, save each exit and move onto the next.

    In my original code the macro would cycle through the files sucessfully and display a message telling the user how many files were processed, but upon opening the csv files in wordpad some of the dates would have switched from YYYYY-MM-DD to YYYY-DD-MM, generally these were where the MM-DD were both under 12, i.e. the month was < December.

    This code is below:
    Please Login or Register  to view this content.
    The improved code provided by Philb1 sucessfully changed the dates in the first csv file processed but doesn't cycle through the remainder of the files in the folder, or display a message telling the user how many files have been processed.

    The code is:

    Please Login or Register  to view this content.
    Would anyone know what's wrong with the code above and why it's stopped cycling through the files?

  2. #2
    Forum Contributor
    Join Date
    05-04-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    125

    Re: VBA not cycling through and processing all files in folder

    I've attached the vba in a workbook for anyone if that's easier.

    Regards

    David
    Attached Files Attached Files

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

    Re: VBA not cycling through and processing all files in folder

    There is no loop in that code.

    You could try this version of your original code:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  4. #4
    Forum Contributor
    Join Date
    05-04-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    125

    Re: VBA not cycling through and processing all files in folder

    Hi Rory, that seem to work very well.

    Can I ask how you managed to get the format to stay as YYYY-MM-DD even for the lines where the DD-MM could be transposed? In all of my attempts I'd get 2014-04-06 when it should have been 2014-06-04, and the formula "=TEXT(RC[-2],""YYYY-MM-DD"")" looks identical to my original one.

    Regardless that's a fantastic result and much appreciated.

    Cheers

    David

  5. #5
    Forum Contributor
    Join Date
    05-04-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    125

    Re: VBA not cycling through and processing all files in folder

    Hi Rory, that seem to work very well.

    Can I ask how you managed to get the format to stay as YYYY-MM-DD even for the lines where the DD-MM could be transposed? In all of my attempts I'd get 2014-04-06 when it should have been 2014-06-04, and the formula "=TEXT(RC[-2],""YYYY-MM-DD"")" looks identical to my original one.

    Regardless that's a fantastic result and much appreciated.

    Cheers

    David

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

    Re: VBA not cycling through and processing all files in folder

    It was the addition of the Local argument here:
    Please Login or Register  to view this content.

+ 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. [SOLVED] Multitude of random errors when cycling through workbooks in a folder to copy a range
    By LXN in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-23-2013, 12:29 PM
  2. Replies: 1
    Last Post: 10-10-2012, 07:09 AM
  3. cycling through all sub-folders in a folder
    By dyesol in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-15-2011, 10:31 AM
  4. Cycling through files in a folder
    By KateMolloy in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-28-2009, 04:18 PM
  5. Cycling through all worbooks in a folder
    By Ben in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-15-2006, 06:40 AM

Tags for this Thread

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