+ Reply to Thread
Results 1 to 12 of 12

Find/Replace with script

  1. #1
    Forum Contributor
    Join Date
    10-10-2015
    Location
    nj
    MS-Off Ver
    Office 2021
    Posts
    203

    Find/Replace with script

    Hi all,

    Does anyone have a script I can run that will find/replace with values provided in a column?

    Column D has values separated by commas, I specified in column J the values and in column K what they should be replaced with. Ideally a click and drag is what I am looking for.
    Attached Files Attached Files

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,519

    Re: Find/Replace with script

    This will do it. Not a click and drag though.

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Forum Contributor
    Join Date
    10-10-2015
    Location
    nj
    MS-Off Ver
    Office 2021
    Posts
    203

    Re: Find/Replace with script

    Quote Originally Posted by mike7952 View Post
    This will do it. Not a click and drag though.

    Please Login or Register  to view this content.
    Mike a bit of a noobie... What column is this going in, and uh more or less what am I doing with it lol.. Making it a formula with an equal sign?

  4. #4
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,519

    Re: Find/Replace with script

    You asked for a script so I assumed you was familiar with macros. Attached is your example work. To run the code press Ctrl + m at the same time. You can press Alt + F11 to view code. Also can press Alt + F8 to bring up a Macro Dialog box where you can see the Macros
    Attached Files Attached Files
    Last edited by mike7952; 11-28-2016 at 11:55 PM.

  5. #5
    Forum Contributor
    Join Date
    10-10-2015
    Location
    nj
    MS-Off Ver
    Office 2021
    Posts
    203

    Re: Find/Replace with script

    Quote Originally Posted by mike7952 View Post
    You asked for a script so I assumed you was familiar with macros. Attached is your example work. To run the code press Ctrl + m at the same time. You can press Alt + F11 to view code. Also can press Alt + F8 to bring up a Macro Dialog box where you can see the Macros

    Mike, just wanted to take a sec and thank you for everything thus far. I got it to work perfectly in the example sheet I posted

    I am trying to apply it to a real example now and see to be stuck. Can you take a look at this one?

    The values I am trying to replace are in J & K again.
    Attached Files Attached Files

  6. #6
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,519

    Re: Find/Replace with script

    Give this a try

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    10-10-2015
    Location
    nj
    MS-Off Ver
    Office 2021
    Posts
    203

    Re: Find/Replace with script

    Quote Originally Posted by mike7952 View Post
    Give this a try

    Please Login or Register  to view this content.
    Tried that but it doesn't seem to run? Pressed control + M and all.

  8. #8
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,519

    Re: Find/Replace with script

    My bad change this line

    FROM
    Please Login or Register  to view this content.
    TO
    Please Login or Register  to view this content.

  9. #9
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Find/Replace with script

    Edit Please ignore. See post #11.

    If you are interested in a formula solution array enter this (Ctrl + Shift + Enter) in C1 and fill down.

    =IFERROR(INDEX($K$1:$K$26,INDEX(MATCH(TRIM(MID(SUBSTITUTE($D1,",",REPT(" ",99)),(COLUMN($A:$B)-1)*99+1,99)),$J$1:$J$26,0),1))&","&INDEX($K$1:$K$26,INDEX(MATCH(TRIM(MID(SUBSTITUTE($D1,",",REPT(" ",99)),(COLUMN($A:$B)-1)*99+1,99)),$J$1:$J$26,0),2)),INDEX($K$1:$K$26,MATCH($D1,$J$1:$J$26,0)))
    Last edited by FlameRetired; 11-29-2016 at 09:33 PM.
    Dave

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Find/Replace with script

    Edit Please ignore. See next post.

    Or if you wish to re-use the User Defined Function Concatall from previous posts array enter this.

    =IFERROR(Concatall(INDEX($L$1:$L$26,INDEX(MATCH(TRIM(MID(SUBSTITUTE($E1,",",REPT(" ",99)),(COLUMN($A:$B)-1)*99+1,99)),$K$1:$K$26,0),N(IF(1,{1,2})))),","),INDEX($L$1:$L$26,MATCH($E1,$K$1:$K$26,0)))
    Last edited by FlameRetired; 11-29-2016 at 09:32 PM.

  11. #11
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Find/Replace with script

    This instead. Still uses Concatall and is array entered. I had overlooked that there are sometimes more than two codes in column D cells.

    =Concatall(INDEX($K$1:$K$26,INDEX(MATCH(TRIM(MID(SUBSTITUTE($D1,",",REPT(" ",99)),(ROW(INDIRECT("1:"&LEN($D1)-LEN(SUBSTITUTE($D1,",",""))+1))-1)*99+1,99)),$J$1:$J$26,0),N(IF(1,ROW(INDIRECT("1:"&LEN($D1)-LEN(SUBSTITUTE($D1,",",""))+1)))))),",")

  12. #12
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,899

    Re: Find/Replace with script

    UDF ...
    Please Login or Register  to view this content.
    Use:

    =FindAndReplace(D1,$J$1:$K$26)
    Attached Files Attached Files
    Last edited by Phuocam; 11-29-2016 at 11:03 PM.

+ 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. Enhancing FIND/REPLACE script
    By terryhenderson in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-06-2015, 06:44 AM
  2. Script for Find Replace Operation
    By binar in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-20-2010, 01:05 PM
  3. Find and replace script
    By grandmastr in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-26-2010, 12:59 PM
  4. Find and replace script
    By mambotech in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-28-2009, 05:07 AM
  5. Mass Find & Replace Script?
    By TyneeTom in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-24-2009, 03:41 AM
  6. Find and replace script / macro?
    By luu980 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 03-09-2009, 01:59 PM
  7. VBA Script. Find & Replace.
    By denis.samoilov in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-07-2008, 11:14 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