Conditional Find and Replace

dhancy

Board Regular
Joined
Jul 10, 2013
Messages
120
Office Version
  1. 2016
Platform
  1. Windows
Hello,

Is there a way to find and replace based on the value of another cell in that row?

For example, in the image below, I want to replace "a" with "xxx" in column B, but only when column A has the value of "yes"

Is there a way to do this, either in a standard formula or in VBA?

Thanks!
Dennis
 

Attachments

  • excel find and replace.jpg
    excel find and replace.jpg
    7.4 KB · Views: 5

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
You can add another column with this formula
Excel Formula:
=IF(A1="yes",SUBSTITUTE(B1,"a","xxx"),B1)
This assumes you want a partial match. That is, if B has "cat" it will change it to "cxxxt".

If you need to use this result in column B instead of a new column, you can Copy the new column and Paste Values to column B.
 
Upvote 0
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

A reasonably simple manual way would be to
- insert a header row
- AutoFilter column A for 'yes' and column B for 'a'
- Select column B data and use F5-> Special -> Visible cells only
- Type xxx and press Ctrl+Enter
- Unfilter
 
Upvote 0

Forum statistics

Threads
1,215,684
Messages
6,126,199
Members
449,298
Latest member
Jest

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