Replace Text in a Range of Cells

gberg

Board Regular
Joined
Jul 16, 2014
Messages
180
Office Version
  1. 365
Platform
  1. Windows
I am looking for a formula to replace text in a range of cells. The information will always start in Cell "I14" but will very in how long the list is. I have come up with a way to add a XLOOKUP formula into the affected cells but it uses "ActiveCell" which is always I14 so everything is based on what is in I14. Is there a way to have the date from individual cells (i.e. I14, I15, I16, etc.) in the following?

VBA Code:
Sub Replace()

    Range("I14").Select
    Range(Selection, Selection.End(xlDown)).Select

    Dim myRange As Range
    Set myRange = Selection
    myRange.Formula = _
        "=XlOOKUP(" & """" & ActiveCell & """" & ",TBL_Status[STATUS],TBL_Status[Replacement],"""",0)"


End Sub

Thanks
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
To write a formula to a range, you can just write the formula for 1st row and the subsequent row will change automatically. Example:

VBA Code:
Sub Replace()

Range("A1", "A10").Formula = "= B1"

End Sub

You can see the formula in A1 to A10 as
A1 > =B1
A2 > =B2
A3 > =B3

and so on.
 
Upvote 0

Forum statistics

Threads
1,214,394
Messages
6,119,262
Members
448,880
Latest member
aveternik

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top