+ Reply to Thread
Results 1 to 7 of 7

Creating a macro to search string in a range of cells and replace while leaving original

  1. #1
    Registered User
    Join Date
    07-25-2014
    Location
    Tijuana, Mexico
    MS-Off Ver
    Office 365 Pro Plus
    Posts
    4

    Creating a macro to search string in a range of cells and replace while leaving original

    Hi all, I am new to this forum. Hope I can get some help on this matter.

    So I was given the task to translate some procedure instructions in an Excel file from English to Spanish. These are very simple instructions and in most cases repetitive throughout the document. There are a lot of instances where the instructions are the same except for a #. They are meant to be modified within the cell as the text that appears in the cell will be printed exactly as it appears.There are several instructions in the cell, it is basically a long continuous string in the cell. My idea is to create a macro that can search that range of cells for the instruction, replace it with the Spanish equivalent while leaving the original English instruction in the cell. Any ideas on how can I go and do this on Excel? Any links to other forum threads I can read on ?

    Thanks in advance.

    JCarlos
    Last edited by JCarlos; 07-25-2014 at 02:40 PM.

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Creating a macro to search string in a range of cells and replace while leaving origin

    I think the best way to start is to create a list in a separate sheet which has maybe the English version in say Column A and the Spanish version in Column B of the various instructions. Attach a copy of the workbook to this thread with some sample (non sensitive data). Review the Forum Rule Page on how to attach samples. Then we could work from there to create a macro.

  3. #3
    Registered User
    Join Date
    07-25-2014
    Location
    Tijuana, Mexico
    MS-Off Ver
    Office 365 Pro Plus
    Posts
    4

    Re: Creating a macro to search string in a range of cells and replace while leaving origin

    Hi John ,

    Thanks for the prompt answer. I attached an oversimplified example of my workbook , just to get the sense of what I am trying to do. Hope this helps to clarify that.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Creating a macro to search string in a range of cells and replace while leaving origin

    Does this help?

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-25-2014
    Location
    Tijuana, Mexico
    MS-Off Ver
    Office 365 Pro Plus
    Posts
    4

    Re: Creating a macro to search string in a range of cells and replace while leaving origin

    Hi John,

    I tried running it and for some reason the first time I tried it it gave me a range error (runtime error 9) so I changed the name of my ws2 to just 'translation' and it runs. However, the only thing printed out in the cell are the "\\" which are attached in the original cell at the end of the original statement. But no equivalent Spanish translation is printed out. Any ideas why?

    Thanks in advance

  6. #6
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Creating a macro to search string in a range of cells and replace while leaving origin

    Hi JCarlos,
    try also this
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by nilem; 07-29-2014 at 11:25 AM.

  7. #7
    Registered User
    Join Date
    07-25-2014
    Location
    Tijuana, Mexico
    MS-Off Ver
    Office 365 Pro Plus
    Posts
    4

    Re: Creating a macro to search string in a range of cells and replace while leaving origin

    Hi nilem,

    I tried your code. When I click on the box, it gives me a copy of the original instructions in the cell but no spanish equivalent. It gives me " \Special Instruction 1\Special Instruction 2\Special Instruction 3\\Special Instruction 1\Special Instruction 2\Special Instruction 3." Is there something missing in the code that relates each special instruction to the Spanish equivalent ? Ultimately the idea is to have the following in a single cell : "Spanish SI1\Spanish SI2\ Spanish SI3\\Special Instruction1\Special Instruction2\Special Instruction3.

    Thanks

+ 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. Creating search box in cell - Currently using Macro 'Range to search' *HELP*
    By jacko058 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-14-2014, 05:24 AM
  2. [SOLVED] Search through cells, if I find a string (external Link), replace it with a formula
    By Vaslo in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-17-2012, 04:41 PM
  3. Replies: 5
    Last Post: 03-08-2012, 01:50 AM
  4. How to insert Cells VALUE (Search and Replace Macro)
    By NatanZ in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-30-2010, 01:58 PM
  5. Replies: 24
    Last Post: 04-15-2009, 09:24 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