+ Reply to Thread
Results 1 to 9 of 9

Automatically find and replace texts and numbers

  1. #1
    Registered User
    Join Date
    09-09-2013
    Location
    london
    MS-Off Ver
    Excel 2007
    Posts
    21

    Automatically find and replace texts and numbers

    hello.

    I have an excel file with many users

    i need certain texts to be automatically replaced once a user enters them.

    Range should be anywhere in the worksheet

    for example

    B/RED into Brick Red

    DARK GREEN into Dark Green

    S/BLU into Sky Blue

    C/GREY. into Charcoal Grey

    and so on up to 10 or more

    Can anyone help me in achieving what i need ?

  2. #2
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Automatically find and replace texts and numbers

    Hi
    right click on the sheet's tab, select 'view code', and copy the code below into your worksheet's code area

    whenever you change a cell's contents on that sheet, the macro will look in that cell for the values in the first array ('ToRep'). If found, it will replace this with the corresponding value in the second array ('RepWith'). Note both are case sensitive and need to contain the same number of values.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-09-2013
    Location
    london
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Automatically find and replace texts and numbers

    Thanx, Nikky for your reply

    i am getting

    Compile Error: Ambiguous name detected: Worksheet_Change
    in my current file.

    That must be because i have another code there also for a different purpose

    Please Login or Register  to view this content.

    This problem I assume so because I created new file and your code works perfectly well in the new file.

    But i need your code in my current file which is having another code for a different purpose.

    any way to solve this problem ?

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Automatically find and replace texts and numbers

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-09-2013
    Location
    london
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Automatically find and replace texts and numbers

    thanx Yudlagar,

    Its working but with a slight annoyance.

    i get error message while moving a row via a code

    Run-time error '13':
    Type mismatch

    Although things get done but the message is annoying

    my first code is for column K,
    What is does is it automatically moves the whole row from the current unprotected sheet to another protected sheet once a date is entered in column K.

    the code in the module1 is
    Please Login or Register  to view this content.
    Is there any way i can get rid of the error message ?

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Automatically find and replace texts and numbers

    Hard to know if/how the two are related without access to the whole workbook. You could try disabling events and see if that helps:
    Please Login or Register  to view this content.
    that will stop the worksheet change macro from running.

  7. #7
    Registered User
    Join Date
    09-09-2013
    Location
    london
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Automatically find and replace texts and numbers

    can you please download the file and have a look ?
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Automatically find and replace texts and numbers

    I think the problem is in your instr function. Instr has 3 arguments, the first one being start position, so presumably you want:
    Please Login or Register  to view this content.
    instead of
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    09-09-2013
    Location
    london
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Automatically find and replace texts and numbers

    i dont see any difference in outcome after replacing ....did you ?

+ 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] Find and replace - problem with automatically changing formatting
    By jwa90010 in forum Excel General
    Replies: 6
    Last Post: 06-27-2014, 05:36 AM
  2. Macro to search through button texts and replace
    By sm9748 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-21-2013, 10:35 AM
  3. [SOLVED] Macro to Automatically Find/Replace
    By Cansa in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-27-2012, 10:57 AM
  4. [SOLVED] How to Find and Replace a string if cell does not contain certain texts.
    By windcloud2 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-04-2012, 01:04 PM
  5. Macro question - need to automatically find and replace multiple content
    By rodeman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-05-2008, 06:26 PM

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