Word endings

nickharr

Active Member
Joined
Apr 8, 2008
Messages
251
Office Version
  1. 2019
Platform
  1. Windows
Hi - is there any formula that could detect the last two letters in a word and depending on what those letters are, substitue with other letters? They are Spanish words I'm working with. So, if the word in A1 was "hablar" and in A2 I wanted "hablas", I would use the LEFT expression to remove and replace the last two letters. This would be okay if all the words finished with the same two letters but some don't! Therefore in A3 I might have the word "abrir" and this needs to change in A4 to "abres". Would there be a formula to cover - if the word in A1 or A3 ends in "ar" replace with "as" or if it ends in "ir" replace with "es"? I'm not able to work this out at all so any help would be gratefully recieved!
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
How about
=LEFT(A2,LEN(A2)-2)&IF(RIGHT(A2,2)="ar","as",IF(RIGHT(A2,2)="ir","es",RIGHT(A2,2)))
 
Upvote 0
Totally different formula than Fluff, lol.

Book1
AB
1HablarHablas
2AbrirAbres
Sheet1
Cell Formulas
RangeFormula
B1:B2B1=IF(MID(A1,LEN(A1)-1,1)="a",REPLACE(A1,LEN(A1)-1,2,"as"),REPLACE(A1,LEN(A1)-1,2,"es"))
 
Upvote 0
If you have a lot of these to change, you could use a lookup table like

Book1
ABCHI
1
2hablarhablas
3abrirabresaras
4hablashablarires
5abresabrirasar
6nothingnothingesir
HPV
Cell Formulas
RangeFormula
B2:B6B2=LEFT(A2,LEN(A2)-2)&IFERROR(VLOOKUP(RIGHT(A2,2),$H$3:$I$6,2,0),RIGHT(A2,2))
 
Upvote 0
Other option

Another option considering the infinitive "er", although you will have some problems with some verbs, for example "ir" ("vas"), "ser" ("eres")

Book1
AB
1
2hablarhablas
3abrirabres
4comercomes
5palabrapalabra
6somesome
7chalechale
8ires
9serses
Hoja2
Cell Formulas
RangeFormula
B2:B9B2=LEFT(A2,LEN(A2)-2)&SUBSTITUTE(LOOKUP(RIGHT(A2,2),{"ar","er","ir","??"},{"as","es","es","@"}),"@",RIGHT(A2,2))
 
Upvote 0
Wow guys! Thank you so much! I've just tried a couple of your suggestions and they work perfectly for what I'm trying to achieve. I need a bit if time to work out which method will be best for me but I really appreciate the time you have all taken to reply. Many thanks.
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0
=LEFT(A2,LEN(A2)-2)&SUBSTITUTE(LOOKUP(RIGHT(A2,2),{"ar","er","ir","??"},{"as","es","es","@"}),"@",RIGHT(A2,2))
Not sure that Dante's formula will work too well if you have words with different endings not catered for in the array.
"??" might work for anything that is >"ir", but for anything in the range "as" to "eq" or "es" to "iq" the approximate match of lookup is going to pull the wrong result from the array.
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,276
Members
449,075
Latest member
staticfluids

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