Search for a word in a cell and replace the whole cell

Co Don

New Member
Joined
Jun 10, 2007
Messages
20
All,

Appreciate for the all the help:

How can I search for a specific word in the Cell's content if found, then replace the whole cell's content with this specific word. If not found, no change.

for example:
If(A2 = "MLB"), then replace A2's content with just MLB, if false, do nothing).

I tried playing around with Lookup, Vlookup and If function, but not quite get the answer....

Thanks you very much....

Co Don.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
You can't change another cell's value with a formula.

But perhaps:
Select Column A.
Click Edit, then Find and Replace (or CTRL-H)
After Find What, put *MLB*
After Replace With, put MLB
Click on Replace All

or as a macro:
Code:
Sub ChangeMLB()
Range("A:A").Replace What:="*MLB*", Replacement:="MLB", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
End Sub
 

Co Don

New Member
Joined
Jun 10, 2007
Messages
20
Thanks....

I tried the first option you suggested (Find and Replace), but I didn't put * in front of and after the MLB.....

But now with your suggestion, it works!!!

Many thanks.

Co Don
 

Forum statistics

Threads
1,181,648
Messages
5,931,212
Members
436,784
Latest member
amuljono

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
Top