Function to repeatedly replace string one-at-a-time via a lookup table

smallxyz

Active Member
Joined
Jul 27, 2015
Messages
393
Office Version
  1. 2021
Platform
  1. Windows
ABCDEF
1a1a2a3@ + @+@a1+a2+a3
2b1b2b3@ + @+@b1+b2+b3
3c1c2c3@ + @+@c1+c2+c3


Suppose I have some texts at range "E1:E3", with the value "@+@+@".

I also have another lookup table ranged at "A1:C3"

I hope that, for each output row in column "F", the "@" character in the column "E" text will be replaced one at a time correspondingly by each lookup value in the row table, following a left-to-right column-wise direction in a row, as shown in the above table

e.g. in cell "F1", one possible formula can be =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(E1,A1,"",1),B1,"",1),C1,"",1)

But as you can see, this formula is very cumbersome and inflexible in case I wish to expand the lookup table to 4 or more columns.



It will be great if there is a much neater and flexible formula in this case.

Thanks.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
if you have 365 (please update your profile, so your version appears on your button).
Excel Formula:
=TextJoin(" + ",,B2:D2)


Book1
ABCDEFG
11a1a2a3@ + @+@a1 + a2 + a3
22b1b2b3@ + @+@b1 + b2 + b3
33c1c2c3@ + @+@c1 + c2 + c3
Sheet3
Cell Formulas
RangeFormula
G1:G3G1=TEXTJOIN(" + ",,B1:D1)
 
Upvote 0
if you have 365 (please update your profile, so your version appears on your button).
Excel Formula:
=TextJoin(" + ",,B2:D2)


Book1
ABCDEFG
11a1a2a3@ + @+@a1 + a2 + a3
22b1b2b3@ + @+@b1 + b2 + b3
33c1c2c3@ + @+@c1 + c2 + c3
Sheet3
Cell Formulas
RangeFormula
G1:G3G1=TEXTJOIN(" + ",,B1:D1)
Sorry for insufficient information.
The original text "@+@+@" for replacement may change to "@ and @ except @ " or any text content that carries "@". The target is to replace each "@" by the corresponding lookup value one-at-a-time in the same row.
 
Upvote 0
As awoohaw asked, 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’)
 
Upvote 0
As awoohaw asked, 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’)
Updated. Thanks for reminder.
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

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