How to substitute whole word with different designated letters?

H

HammerJoe

Hi,

Is there a way to substitute letters from a word in a cell, with
predifined letters for the whole word?

Cell A1 contains the word. OLE.
Cells O1:O26 have the letters of the alphabet and cells P1:p26 have
the replacement letter.

I need a formula on cell A15 that will take the word OLE in cell A1
and replace all those letters with its match on cells P1:p26.

Thanks
 
M

Mike H

Hi,

Not sure about a formula but here's a UDF. Alt+F11 to open VB editor, Right
click 'This workbook' and insert module and paste the code below in
in A15 enter the formula
=Subst(A1)


Function Subst(oldstring As String) As String
For x = 1 To Len(oldstring)
Mid(oldstring, x, 1) = WorksheetFunction.VLookup(Mid(oldstring, x, 1), _
ActiveSheet.Range("O1:p26"), 2, False)
Next
Subst = oldstring
End Function

Mike
 
S

ShaneDevenshire

Hi,

Here is a formula approach:

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,LEFT(A1),LOOKUP(LEFT(A1),C1:C26,D1:D26)),MID(A1,2,1),LOOKUP(MID(A1,2,1),C1:C26,D1:D26)),RIGHT(A1),LOOKUP(RIGHT(A1),C1:C26,D1:D26))

I used the range C1:C26 and D1:D26 you should adjust those for you column O:p.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top