More than 64 levels of =Substitute

qwzky

Board Regular
Joined
Jul 22, 2021
Messages
53
Office Version
  1. 2021
  2. 2016
Platform
  1. Windows
Hi, community!
I am working at a sheet that should substitute letters and groups of letters with other letters. The problem is: this requires me more than 64 levels of nesting. How can I shorten this formula? Or is there any alternative to =Substitute function?

Fonetică 2.xlsx
BCDE
2
3Wordtăierii
4
12
13Phonetic Translation[tă-ie-rii]
14
17
18SoundsVowels: [ăeii] ● Consonants: [tr] ● Semivowels:[iii]
19
Sheet3
Cell Formulas
RangeFormula
D13D13=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(Sheet1!F8,"ači","ač"),"eči","eč"),"rči","rč"),"iči","ič"),"oči","oč"),"uči","uč"),"ăči","ăč"),"âči","âč"),"aĝi","aĝ"),"eĝi","eĝ"),"iĝi","iĝ"),"oĝi","oĝ"),"uĝi","uĝ"),"ăĝi","ăĝ"),"lĝi","lĝ"),"aK'i","aK'"),"eK'i","eK'"),"iK'i","iK'"),"oK'i","oK'"),"uK'i","uK'"),"ăK'i","ăK'"),"âK'i","âK'"),"aG'i","aG'"),"eG'i","eG'"),"iG'i","iG'"),"oG'i","oG'"),"uG'i","uG'"),"ăG'i","ăG'"),"âG'i","âG'"),"K'iu","K'u"),"K'ia","K'a"),"ĝii","ĝi"),"lči","lč"),"nči","nč"),"nĝi","nĝ")
D18D18="Vowels: "&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(D13,"b",""),"k",""),"d",""),"f",""),"g",""),"h",""),"j",""),"l",""),"m",""),"n",""),"p",""),"r",""),"s",""),"ș",""),"t",""),"ț",""),"v",""),"z",""),"č",""),"Č",""),"ĝ",""),"Ĝ",""),"K'",""),"G'",""),"oi","o"),"ie","e"),"-","")&" ● Consonants: "&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(D13,"a",""),"e",""),"i",""),"o",""),"u",""),"ă",""),"î",""),"â",""),"-","")&" ● " & "Semivowels:"&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(D13,"oi","i"),"oa","o"),"ie","i"),"ui","i"),"ai","i"),"eu","u"),"ei","i"),"iu","i"),"a",""),"b",""),"k",""),"d",""),"f",""),"g",""),"h",""),"j",""),"l",""),"m",""),"n",""),"p",""),"r",""),"s",""),"ș",""),"t",""),"ț",""),"v",""),"z",""),"č",""),"Č",""),"ĝ",""),"Ĝ",""),"K'",""),"G'",""),"re",""),"e",""),"ă",""),"î",""),"â",""),"-","")
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Here is a UDF that you can try:

VBA Code:
Function SubstituteLevels(s As String, rng As Range)
  Dim c As Range
  For Each c In rng
    s = Replace(s, c.Value, c.Offset(, 1).Value)
  Next
  SubstituteLevels = s
End Function

You should use helper columns like this:
Dante Amor
ADEGHIJKLMN
1VowelsConsonantsSemivowels
2OriginalNewOriginalNewOriginalNewOriginalNew
3ačibaoii
4ečikeoao
5rčidiiei
6ičifouii
7očiguaii
8učihăeuu
9ăčiăčjîeii
10âčiâčlâiu
11aĝim-ai
12eĝinb
13[tă-ie-rii]iĝipk
14oĝird
15uĝisf
16ăĝiăĝșg
17lĝith
18Vowels: [ăeii] ● Consonants: [tr] ● Semivowels:[iii]aK'iaK'țj
19eK'ieK'vl
20iK'iiK'zm
21oK'ioK'čn
22uK'iuK'Čp
23ăK'iăK'ĝr
24âK'iâK'Ĝs
25aG'iaG'Kș
26eG'ieG'Gt
27iG'iiG'oioț
28oG'ioG'ieev
29uG'iuG'-z
30ăG'iăG'č
31âG'iâG'Č
32K'iuK'uĝ
33K'iaK'aĜ
34ĝiiĝiK
35lčiG
36nčire
37nĝie
38ă
39î
40â
41-
Hoja16
Cell Formulas
RangeFormula
D13D13=SubstituteLevels(Sheet1!F8,G3:G37)
D18D18="Vowels: "&SubstituteLevels(D13,I3:I29)&" ● Consonants: "&SubstituteLevels(D13,K3:K11)&" ● Semivowels:"&SubstituteLevels(D13,M3:M41)
 
Last edited:
Upvote 0
Solution
it worked for a second, but now I can't make it. Somehow, I changed something, but can't figure out what exactly. Can you give your insight? (I don't want to reference other sheets; I want to reference cells within the same sheet)


Fonetică 2.xlsx
HIJKLMNOPQRSTUVWXY
1VowelsSemivowelsConsonantsLetter groups to sound groups
2
3Original_VNew_VOriginal_SNew_SOriginal_CNew_COriginalNew
4avaivsbcači
5ăvauvskceči
6îveasvdcčeača
7Wordcârmaciâveivsfcck
8Hyphencâr-macieuvsgc
9Phonetic1[câr-mači]iasvhc
10Phonetic2#NAME?iesvjc
11Phonetic3#NAME?iivslc
12Types of sounds#NAME?iosvmc
13iusvnc
14pc
15rc
16sc
17șc
18tc
19țc
20vc
21zc
22čc
23c
24c
25c
26
27
28
29
30
31
32
33
34
35
Sheet1
Cell Formulas
RangeFormula
J8J8=VLOOKUP(J7,$D$100:$F$706567,3,0)
J9J9=CONCATENATE("["&(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(J8,"ce","če"),"ci","či"),"ge","ĝe"),"gi","ĝi"),"ghe","G'e"),"ghi","G'i"),"x","ks")&"]"))
J10J10=SubstituteLevels(J9,W4:X7)
J11J11=SubstituteLevels(J10,R4:R22)
J12J12="Vowels: "&SubstituteLevels(J11,R4:R22)&" ● Consonants: "&SubstituteLevels(D13,K3:K11)&" ● Semivowels:"&SubstituteLevels(D13,M3:M41)
 
Upvote 0
Don't use merged cells.
In the formula you must enter the cell with the original text, the second parameter must only be a column. It should be the left column.

Look at my example, I only put the left column:
SubstituteLevels(Sheet1!F8,G3:G37)
In this example, the left column is column G, range G3 to G37. The formula assumes that the new value is in the right column.

Follow the prompts according to my example. You will have no problems with the function.
 
Upvote 0
I have tried all the things you said: unmerged cell, only the left column. I also tried other things I said to me (ha-ha-ha): only the right column, both columns, followed the „Sheet1!F8” and changed to the word cell... I will unmark your solution, in order to not confuse the community, until we get this through :)
 
Upvote 0
But my solution works. But don't worry, I'll gladly explain again.
This is how you should put the data.

For the formula in cell J12.
The first argument of the formula is J7.
The second argument of the formula is U3:U7. (And that's it.)


In cells U3:U7 you put the original values and in cells V3:V7 you put the new values.
Note: In the formula it is not necessary to put the reference V3 to V7.
Take a look at my example, No merged cells:

varios 20feb2022.xlsm
IJKUV
1Letter groups to sound groups
2
3OriginalNew
4ači
5eči
6čeača
7Wordcârmacick
8Hyphen
9Phonetic1
10Phonetic2
11Phonetic3
12Types of soundsVowels: kârmaki
Hoja3
Cell Formulas
RangeFormula
J12J12="Vowels: "&SubstituteLevels(J7,U3:U7)
 
Upvote 0
Yep, all clear now :) Thank you, Dante! Thank you for your patience! Now it DOES work.
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,984
Messages
6,122,601
Members
449,089
Latest member
Motoracer88

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