Replace specific text with value from another cell
Results 1 to 4 of 4

Thread: Replace specific text with value from another cell
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Feb 2019
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Replace specific text with value from another cell

    Hello all,

    I’m trying to create a macro, but am having some difficulties. I am looking to search a cell (“K2”) for the word Location. Once found I would like to replace that word with the contents located in cell “L2”. This sheet will have many rows and the information within column L will always different. I thought a find replace code would be sufficient, but couldn’t it to work when taking data from a different cell.

    Any help would be greatly appreciated. Thank you!
    Last edited by capo4410; May 30th, 2019 at 05:59 PM.

  2. #2
    Board Regular DanteAmor's Avatar
    Join Date
    Dec 2018
    Location
    México
    Posts
    5,714
    Post Thanks / Like
    Mentioned
    65 Post(s)
    Tagged
    14 Thread(s)

    Default Re: Replace specific text with value from another cell

    Try this

    Code:
    Sub Replace_specific_text()
        Dim c As Range
        For Each c In Range("K1", Range("K" & Rows.Count).End(xlUp))
            n = InStr(1, LCase(c.Value), LCase("Location"))
            If n > 0 Then c.Value = Left(c.Value, n - 1) & c.Offset(0, 1).Value & Mid(c.Value, n + 8)
        Next
    End Sub
    Regards Dante Amor

  3. #3
    New Member
    Join Date
    Feb 2019
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Replace specific text with value from another cell

    Worked perfectly, Dante! Thank you very much!

  4. #4
    Board Regular DanteAmor's Avatar
    Join Date
    Dec 2018
    Location
    México
    Posts
    5,714
    Post Thanks / Like
    Mentioned
    65 Post(s)
    Tagged
    14 Thread(s)

    Default Re: Replace specific text with value from another cell

    Quote Originally Posted by capo4410 View Post
    Worked perfectly, Dante! Thank you very much!
    I'm glad to help you. Thanks for the feedback.
    Regards Dante Amor

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •