Yes, you can modify the formula to perform the replacement if XX or YY is found by using the nested SUBSTITUTE function. Here's how you can do it:
- Assuming your concatenated text is in column A, enter the following formula in cell B2:
Formula:
=SUBSTITUTE(SUBSTITUTE(A2,"XX",""),"YY","")
- This formula uses the SUBSTITUTE function twice, with the second SUBSTITUTE nested inside the first one. The first SUBSTITUTE replaces "XX" with an empty string ("") in the original text, and the second SUBSTITUTE replaces "YY" with an empty string in the result of the first SUBSTITUTE.
- Copy the formula down to the rest of the cells in column B to apply it to the entire column.
- The result will be a new column (column B) with the modified text strings that have "XX" or "YY" removed.
Note that this formula is case-sensitive, so it will only remove "XX" and "YY" if they are in uppercase. If you want to remove them regardless of case, you can use the UPPER function to convert the text to uppercase before applying the SUBSTITUTE function. For example:
Formula:
=SUBSTITUTE(SUBSTITUTE(UPPER(A2),"XX",""),"YY","")
This formula first converts the original text to uppercase using the UPPER function, and then applies the nested SUBSTITUTE functions to remove "XX" and "YY" regardless of case.