+ Reply to Thread
Results 1 to 6 of 6

Macro to replace the data

  1. #1
    Registered User
    Join Date
    03-09-2014
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    85

    Macro to replace the data

    Hi,

    I have nearly 300 text files in one path(C:/Documents).I need a macro to replace the some content present in all the 200 text files at a time.In each text file I need to replace 'Unitedstates' name as USA and 'UNitedKingdom' name replace it as UK in all 300 files.So when I run macro it will replace the values in all 300 files.any one can help me on this.

  2. #2
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Macro to replace the data

    Give this a go. It worked on a few test runs I ran. Change the bits in red as required

    Please Login or Register  to view this content.
    Happy with my advice? Click on the * reputation button below

  3. #3
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Macro to replace the data

    Deleted......

  4. #4
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Macro to replace the data

    Try this small improvement. It will save 300 files being open on your desk top

    For the purists there is a bit of rubbish in this, commented lines that need to be removed and variables declared and not used. I didn't tidy it up because I - well I just didn't. You know what it's like when you change one macro to do the work of another, you get a bit sloppy and take short cuts.

    Please Login or Register  to view this content.
    Last edited by Crooza; 04-10-2015 at 07:09 AM.

  5. #5
    Registered User
    Join Date
    03-09-2014
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    85

    Re: Macro to replace the data

    Hi Crooza,

    Thx for the code.It is adding " symbol also in files data when I run macro and one more issue issue is after run it should display msg like number(count) of files replaced or message like replacing done.Otherwise I need to check every time like data replaced or not.
    Last edited by toravietl; 04-10-2015 at 08:13 AM.

  6. #6
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Macro to replace the data

    Where is the " being added? Is it at the beginning of the file or the end of the file or randomly throughout? Is it replacing the text as requested?

    add msgbox("Finished") to the end of the code if you want a message box

    see revised version. I'm not getting the " anywhere

    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. Use Macro to replace =sum() for large of data
    By SheldonCooper in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-05-2013, 02:10 AM
  2. [SOLVED] copy and replace data using looping macro
    By cmb80 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-16-2012, 05:17 AM
  3. Replace data in excel row using a lookup and macro
    By Jay2512 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-12-2010, 11:21 AM
  4. Optimizing Excel macro to find/replace with the list of data contained in the macro
    By Iceyburnz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-17-2008, 08:41 PM
  5. [SOLVED] Macro to replace data within a worksheet
    By Excell in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-14-2005, 09:20 AM

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