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

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,224,798
Messages
6,181,037
Members
453,013
Latest member
Shubashish_Nandy

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