+ Reply to Thread
Results 1 to 13 of 13

Replace Multiple Text in Column from a List

  1. #1
    Forum Contributor
    Join Date
    03-30-2014
    Location
    https://t.me/pump_upp
    MS-Off Ver
    Excel 2013
    Posts
    274

    Replace Multiple Text in Column from a List

    Hi I am using code which is supposed to work , how ever I am failing to get it working
    I need to replace text in cells in Sheet1 Column "D", with text in sheet2 column "B" which corresponds to sheet2 column "A"
    I have attached a small data file as a sample
    I also rename the first sheet to sheet1 when the worksheet is opened
    Please Login or Register  to view this content.
    Any help will be appreciated and I realise you may have a better way to acheive the end result
    Regards
    Graham
    Attached Files Attached Files
    Last edited by Grahamfeeley; 06-16-2019 at 03:55 AM.

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: Replace Multiple Text in Column from a List

    Confused
    Where is Sheet2 ?

  3. #3
    Forum Contributor
    Join Date
    03-30-2014
    Location
    https://t.me/pump_upp
    MS-Off Ver
    Excel 2013
    Posts
    274

    Re: Replace Multiple Text in Column from a List

    Sorry my bad should be there now
    Regards
    Graham

  4. #4
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: Replace Multiple Text in Column from a List

    Try this.
    Macro/VBA on the two buttons.
    Obviously one button is redundant (only there to reset).
    Simple loops, no formula on sheet, should accommodate expanding lists.
    torachan.
    Attached Files Attached Files

  5. #5
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: Replace Multiple Text in Column from a List

    @Graham.
    I omitted to say, I removed table from sheet 2 and just used the data.
    With the table occupying the entire column it causes a count overflow.
    torachan.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi, try this !


    According to the initial attachment :

    PHP Code: 
    Sub Demo()
                 
    Dim Rg As Range
                 Application
    .ScreenUpdating False
        With Sheet1
    .UsedRange.Columns(4)
            For 
    Each Rg In Range(Sheet2.[A2], Sheet2.Cells(Rows.Count1).End(xlUp))
                .
    Replace Rg.Value2Rg(12).Value2xlWhole
            Next
        End With
                 Application
    .ScreenUpdating True
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

  7. #7
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: Replace Multiple Text in Column from a List

    @Graham
    Your original code actually works when sheet 2 is present.
    See the attached the only amendment I have made is to cover the full range sheet 2, rows 2 to 25.
    torachan.
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,516

    Re: Replace Multiple Text in Column from a List

    Or with Application.Match which could be faster in a larger file
    Please Login or Register  to view this content.
    Last edited by jolivanes; 06-17-2019 at 02:15 AM.

  9. #9
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: Replace Multiple Text in Column from a List

    As a self confessed "speed-freak" I always like to add to my limited knowledge.
    This simple exercise with its various solutions proved very informative.
    To illustrate I put all the solutions together so that they tested the same various ranges.
    Using the OP original list as a 'seed' then created various quantity of row (numbers-->)10,000 to 100,000.
    I declare 'jolivanes' the winner, in second place 'graham', myself a dismal third, with 'Marc' a faller at the first fence.
    torachan.
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,516

    Re: Replace Multiple Text in Column from a List

    For "speed-freak" torachan.
    Another one to try on 300,000+ rows.
    Please Login or Register  to view this content.

  11. #11
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: Replace Multiple Text in Column from a List

    @ jolivanes,
    Unbelievable,
    Your old version 300,000 rows(22.59 secs), 500,000 rows(37.59 secs)
    New version 300,000 rows(1.59 secs), 500,000 rows(2.57 secs)
    Even on my old 'steam driven computer' running Excel 2010.
    Last time I saw performances like that was when I change running my 'dragster' on injection/methanol to supercharger/nitro back in the 70's.
    torachan.

  12. #12
    Forum Contributor
    Join Date
    03-30-2014
    Location
    https://t.me/pump_upp
    MS-Off Ver
    Excel 2013
    Posts
    274

    Re: Replace Multiple Text in Column from a List

    First of all I want to thank you all in this veru enjoyable debate on this code.
    You have helped me a lot and I now consider this query closed as it has been very successful indeed
    You guys are awesome in your help for others, and i was thinking that this is the only user group that is moving forward.
    Thanks a lot to all of you
    Regards
    Graham

  13. #13
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,516

    Re: Replace Multiple Text in Column from a List

    @torachan.
    Nice to hear you like it Don (Garlits)

    @Graham
    Never too old to learn from some old "geezers".
    Good Luck

+ 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] VBA Macro to find text string in one column and replace specific text in another column if
    By bmahfood in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-21-2017, 11:15 AM
  2. Replies: 2
    Last Post: 05-21-2015, 03:09 AM
  3. Aligning multiple lists by matching text in the first column of each list
    By LenaK in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-02-2015, 09:49 PM
  4. Filter column by text, then export column to new workbook, replace searched text with new.
    By Headhunter234 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-30-2015, 07:48 AM
  5. [SOLVED] Search through columns and find specific text and replace that text with header column
    By adamzee in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-09-2014, 11:59 PM
  6. Need a Macro to do a find and replace for multiple text in just one column only
    By beepbeep27 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-10-2012, 12:47 PM
  7. Multiple Find and Replace to replace a list of strings
    By WalterP34 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-11-2011, 07:41 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