+ Reply to Thread
Results 1 to 4 of 4

Need help batch running an excel macro on .csv files and saving back to the same .csv

  1. #1
    Registered User
    Join Date
    05-30-2013
    Location
    FL
    MS-Off Ver
    Excel 2007
    Posts
    3

    Post Need help batch running an excel macro on .csv files and saving back to the same .csv

    What I'm trying to do is run a small bit of macro code on all these files to clean them up so I can compile them into one large list. The command prompt "copy" works well with the csv's so I figured I would just keep them as csv.

    Logically what I'm trying to do looks something like this:

    Open all files in C:\dir\*.csv

    If cell A6="cond" then

    {Macro code 1}

    else

    {Macro code 2}

    Save changes to *.csv

    I have a light background in programming in other languages but no so much in VB so calling/editing/saving files is one of the big hurdles. I am well versed in the Turbo PASCAL programming language though, which is the rotary phone of programming languages.
    Last edited by OutKlast; 05-31-2013 at 09:17 PM.

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Need help batch running an excel macro on .csv files and saving back to the same .csv

    something like
    Please Login or Register  to view this content.
    David
    (*) Reputation points appreciated.

  3. #3
    Registered User
    Join Date
    05-30-2013
    Location
    FL
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Need help batch running an excel macro on .csv files and saving back to the same .csv

    I'm getting a runtime 1004 error. It is telling me:

    'file1.csv' could not be found. Check the spelling of the file name, and verify that the file location is correct.


    file1.csv is my file name and didn't input it anywhere so it seems to be finding the name.

  4. #4
    Registered User
    Join Date
    05-30-2013
    Location
    FL
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Need help batch running an excel macro on .csv files and saving back to the same .csv

    Ok. I solved it. It was an issue with not pointing to the correct drive. I guess you need that extra bit of code referring to the drive.

    Final code if anyone ever searches for this: (BTW, I cut out the If statement from my original question because we decided to only use one type of report)

    Please Login or Register  to view this content.
    Many thanks to David for originally getting me going with some 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