Find/Replace Macro

rmsbcb

New Member
Joined
Nov 18, 2005
Messages
6
I have a column with the following data
cat (dog)
blue
blue (dog)
blue (cat)
How can I write a macro to find all cells within the column that contain "(dog)" and replace the entire contents of the cell with "dog"?
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
When I used that it replaced "(dog)" with "dog" within the cell I need every cell that contains "(dog)" either by itself or as part of a list to be replaced with just "dog"
 
Upvote 0
you can use wildcards to replace the whole string:

Code:
[A1:A20].Replace What:="*(dog)*", Replacement:="dog"

this replaces anything with (dog) in it with just "dog"
 
Upvote 0
Find/Replace use settings from the last pass, so if you're wanting to replace partial cell contents, best to be explicit --

... .Replace What:="xx", Replacement:="x", LookAt:=xlPart
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,824
Members
449,050
Latest member
Bradel

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