Replace all words by new word from another cell

frankdethier

New Member
Joined
Mar 1, 2021
Messages
9
Office Version
  1. 365
Platform
  1. Windows
hi

I need to replace all words in an excel tab ''change initiative'' by a customer specific word, e.g. how the initiative is called at the customers. For example ''BOOST''. But ''Boost'' is not fixed and is a value coming from a survey, so I cannot hard code it in VBA. Is there a way to have VBA code referring to value in particular cell, like B5? Now BOOST is copied into cell B5.

I started with this code, but that obviously doesn't work cause it's replacing everywhere change initiative by ''B2'' --> how can I replace it with the value of cell B2?

Sub TestReplace()
Sheets("Sheet1").UsedRange.Replace What:="change initiative", Replacement:="B2"
End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Should be
VBA Code:
Sub TestReplace()
Sheets("Sheet1").UsedRange.Replace What:="change initiative", Replacement:=Range("B2")
End Sub
 
Upvote 0
Another Aproach

VBA Code:
Sub TestReplace1()
Dim rng As Range
Set rng = Range("A1:f1")
For Each cell In rng
    If cell.Value = "change initiative" Then
        cell.Replace What:="change initiative", Replacement:=Range("b2")
    End If
Next cell
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,924
Messages
6,122,294
Members
449,077
Latest member
Rkmenon

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