Find & Replace With A Twist

VitesseCarOwner

Board Regular
Joined
Jun 29, 2012
Messages
79
I have two columns of data 'A' and 'M'. In column 'A' where the first three characters are 1Q_ I Need to replace with "1QT_" but only if the corresponding cell in column 'M' has the value "Day D". Can anyone help? In the table below the 4th entry would require updating.

Column AColumn M
1Q_ABCDay B
2Q_ABCDay D
3Q_HGFDay C
6Q_POIDay B
1Q_ABCDay D
2Q_ABCDay C
3Q_HGFDay B




<tbody>
</tbody><colgroup><col><col></colgroup>
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

AliGW

Banned
Joined
Mar 9, 2014
Messages
3,628
I think this requires a VBA solution, Godsaint: your formula would have to sit in another column, whereas the OP has asked for a solution to "replace" what is in column A.
 
Upvote 0

BarryL

Well-known Member
Joined
Jan 20, 2014
Messages
1,436
Office Version
  1. 2019
Platform
  1. Windows
  2. MacOS
this should do the trick

Code:
Sub test()
Dim add As String, addr As String
Let add = "A1:A" & Range("A" & Rows.Count).End(xlUp).Row
Let addr = "M1:M" & Range("M" & Rows.Count).End(xlUp).Row
Range(add).Value = Evaluate("IF(" & addr & "=""Day D"",SUBSTITUTE(" & add & ",""1Q_"",""1QT_"")," & add & ")")
End Sub
 
Upvote 0

Forum statistics

Threads
1,190,647
Messages
5,982,116
Members
439,756
Latest member
alice128

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