Original Value2: Index Call Option Risk | Replacing Value2: ^b^Index Call Option Risk^/b^
- To post as a guest, your comment is unpublished.· 2 months agoHello, sameer,
May be the following code can solve your problem, please try it:
Dim Rng As Range
Dim InputRng As Range, ReplaceRng As Range
xTitleId = "KutoolsforExcel"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Original Range ", xTitleId, InputRng.Address, Type:=8)
Set ReplaceRng = Application.InputBox("Replace Range :", xTitleId, Type:=8)
Application.ScreenUpdating = False
For Each Rng In ReplaceRng.Columns(1).Cells
InputRng.Replace what:=Rng.Value, replacement:=Rng.Offset(0, 1).Value, LookAt:=xlWhole, MatchCase:=True
Application.ScreenUpdating = True
Hope it can help you!
- To post as a guest, your comment is unpublished.· 2 months agoskyyang - Thanks. This version does not work in my case since it appears to 'match entire cell contents' but I need to replace only part of the string. I realize now that the example I typed out does not communicate this detail; can you see the JPG I attached instead? Original Range:
Product1 = Call Option: risk 1
Product2 = Index Call Option: risk 2
It's the extra text after the colon that breaks your version. And OP's code is able to ignore the extra text, but can't differentiate between "Call Option Risk:" and "Index Call Option Risk:". Again, I think the picture explains this best, if you could please take another look.