Results 1 to 2 of 2

VBA - replace text within range with contents of another range

Threaded View

  1. #1
    Registered User
    Join Date
    06-01-2014
    Posts
    3

    VBA - replace text within range with contents of another range

    Hi Pros,

    I have a spreadsheet that has data in 2x separate columns (around 150 rows long), named "range1" and "range2". The data in "range1" (Col A) might contain the text "xxx", in which case I want to replace with the text in the coresponding "range2" (Col F). I know that i can probably write code using For Next function to run down the column and make the replacements, but have been trying to use the bulk replace function instead to simply the overall code. Alas, not having much luck! Is this possible to achieve? Here is a sample of the (wrong) code that I am trying to write....... Thanks.


    Sub Macro1()
    '
        Range("range1").Select
        Selection.Replace What:="xxx", Replacement:=Range("range2"), LookAt:=xlPart, _
            SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
            ReplaceFormat:=False
            
    End Sub
    Last edited by grantnorton; 06-16-2018 at 04:27 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA to Clear contents from a range if text appears in a certain cell
    By sherman51 in forum Excel Programming / VBA / Macros
    Replies: 40
    Last Post: 01-20-2018, 04:07 PM
  2. [SOLVED] Replace contents of blank range with contents of the next non-blank range
    By wpryan in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-03-2015, 09:47 AM
  3. [SOLVED] Loop Through Range, Find Text, and Replace Text
    By EnigmaMatter in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-09-2014, 12:01 PM
  4. Search Text of Cell in a range and return the contents
    By knowing in forum Excel General
    Replies: 8
    Last Post: 11-19-2012, 08:57 AM
  5. [SOLVED] How do I clear contents from a range excluding formulas and text?
    By Normezo in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-23-2012, 10:36 AM
  6. Search Text of Cell in a range and return the contents
    By shanipk82 in forum Excel General
    Replies: 3
    Last Post: 11-26-2010, 01:34 PM
  7. [SOLVED] replace a range of #'s e.g. 1.25 to 100 with text in excell
    By Painter in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-27-2005, 04:40 PM

Tags for this Thread

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