Replace multiple specific word with specific cell reference

Sathish G

New Member
Joined
Aug 16, 2017
Messages
44
Office Version
  1. 2013
Platform
  1. Windows
Hi Everyone,

Hope all going good!!!!

I just need your support to replace multiple words with specific cell reference value.

I have attached IMAGE and excel sheet with my requirement.

Please help me to get the code for this.


All your supports are always appreciated.
 

Attachments

  • Capture.JPG
    Capture.JPG
    147.3 KB · Views: 17

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Try:
VBA Code:
Sub test()
    With Columns("A")
        .Replace "sort", Range("D2").Value, xlPart
        .Replace "range", Range("D2").Value, xlPart
    End With
End Sub
 
Upvote 0
You are very welcome. :)
 
Upvote 0
Hi Mumps,

Thanks for the previous code. That's working great but when I replacing the letter sort it replacing the all the sort in columns. Is it possible to replace like this way.

Replace the "sort" and merge with behind letters.



Sub test()
With Columns("A")
.Replace "sort" & "-value-servername", Range("D2").Value, xlPart
.Replace "range" & -"range-value", Range("D2").Value, xlPart
End With
End Sub
 
Upvote 0
It would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach a screenshot (not a picture) of your sheet. Alternately, you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. You have your data in column A. Include the expected results in column B for each value in column A. (de-sensitized if necessary).
 
Upvote 0
I'm sorry but column B does not contain the expected results as I had requested in Post #6.
Include the expected results in column B for each value in column A.
 
Upvote 0
Try in the 'B2' cell (copy down)
Code:
=IF(AND(ISERROR(SEARCH("sort",A2,1))=FALSE,ISERROR(SEARCH("range",A2,1))=TRUE,ISERROR(SEARCH("value",A2,1))=FALSE)=TRUE,SUBSTITUTE(A2,("Sort"),$D$2,1),IF(AND(ISERROR(SEARCH("sort",A2,1))=FALSE,ISERROR(SEARCH("range",A2,1))=FALSE,ISERROR(SEARCH("value",A2,1))=FALSE)=TRUE,SUBSTITUTE(A2,("range"),$D$2,1),IF(AND(ISERROR(SEARCH("sort",A2,1))=TRUE,ISERROR(SEARCH("range",A2,1))=TRUE,ISERROR(SEARCH("value",A2,1))=FALSE)=TRUE,SUBSTITUTE(A2,("value"),$D$2,1),"")))
 
Upvote 0

Forum statistics

Threads
1,214,875
Messages
6,122,037
Members
449,062
Latest member
mike575

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