+ Reply to Thread
Results 1 to 5 of 5

Macro for find and replacing values in multiple CSVs

  1. #1
    Registered User
    Join Date
    10-03-2011
    Location
    Magna, UT
    MS-Off Ver
    Excel 2008
    Posts
    3

    Macro for find and replacing values in multiple CSVs

    Hi, I am in need of a macros for my research project. Here is what I need it to do:

    -Change all of the 1 values to Y and the 0 values to N in the last column of each CSV file.
    -I need it to be able to do this for about 900 files without opening each file individually.

    I would be super appreciative of anyone who could help.

    Thank you
    Attached Files Attached Files
    Last edited by kali237; 10-08-2011 at 02:33 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro for find and replacing values in multiple CSVs

    Hi Kali, welcome to the forum.

    I should be able to give you a little macro to do that for you. To be certain I get it right on the first try, please provide:

    1) An example CSV file in the original form.
    2) An example of the same CSV file in an AFTER form.
    3) Give me the folder path to where these CSVs will be stored.

    Click GO ADVANCED and use the paperclip icon to post up a copy of your CSVs.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    10-03-2011
    Location
    Magna, UT
    MS-Off Ver
    Excel 2008
    Posts
    3

    Re: Macro for find and replacing values in multiple CSVs

    Attached are before and after files. I'm not sure what directory to save them in, but I know enough to be able to change the file path in the VBA scripting interface.

    Thanks!

  4. #4
    Registered User
    Join Date
    10-03-2011
    Location
    Magna, UT
    MS-Off Ver
    Excel 2008
    Posts
    3

    Re: Macro for find and replacing values in multiple CSVs

    Hmm... I attached the separate files, I guess it didn't work. Zip is at the top of the thread.

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro for find and replacing values in multiple CSVs

    This macro will do it, just edit the one variable at the top fPath to the path where your CSVs are stored. On my system it processed 900 CSV files in about 4 minutes.

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 10-09-2011 at 08:18 AM.

+ 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