Find names and replace with translations

MrWouters

New Member
Joined
Aug 13, 2014
Messages
13
Hi,

I previously had some help from Istvan extracting the %'s of fabrics from certain cells. Now I would need to translate the different fabric types, just the names not the %'s of course.

So I have the English names as starting point. Now I need to translate them to Dutch and French (more in the future, but lets start with this)
but again, I only need to replace the fabric name so the x-amount of % needs to stay in front. I've taken a random example below.

Column AN Column AO Column AP
Material Description ENMaterial Description FRMaterial Description NL

<tbody>
</tbody>
40% Acrylic, 33% Polyester, 27% Wool

<tbody>
</tbody>
etc.........

In another file, I have the English names in Column A, French in Column B, Dutch in Column C.

ABC
EngFrNL
Acrylic Acrylique Acryl
PolyesterPolyesterPolyester
Wool Laine Wol

<colgroup><col width="72" span="3" style="width:54pt"> </colgroup><tbody>
</tbody>

Is there a formula I can use for this? I'm guessing any space between a two (or more) component fabric name will present a problem? So I would have to connect it with a - or something again?

Many thanks in advance once again for any support!

Regards,
Wouter
 
Last edited:
Try this version instead:

Code:
Function translate(s As String, tbl As Range, col As Long) As String
Dim i As Long
translate = Replace(s, ",", " |")
For i = 1 To tbl.Rows.Count
    translate = Trim(Replace(" " & translate & " ", " " & _
    tbl.Cells(i, 1) & " ", " " & tbl.Cells(i, col) & " ", , , vbTextCompare))
Next i
translate = Replace(translate, " |", ",")
End Function
 
Upvote 0

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Briljant! :) What is changed? I see it's a bit longer and I see a lot of "quotes"
Does this remove or ignore any possible spaces between words in the translation table or something? Because I did already try TRIM to remove all that.

By the way; this code would work with any random table of translations right? Say for instance I have color names in different languages. I do the same steps right?
Nothing in the code would need to change?

Well, either way, huge thanks! Genious stuff, probably childsplay for you guys, but I love it!

Have a great evening!
 
Upvote 0
What is changed?

The "hair" in Mohair was being replaced by "Poil/crin" so instead of looking for "hair" in the string we are now looking for {space}hair{space}.

By the way; this code would work with any random table of translations right? Say for instance I have color names in different languages. I do the same steps right?
Nothing in the code would need to change?

It's not as generalised as I would have liked, but it will work for words separated by spaces or commas. I'm still in the learning stages with this stuff and I'm sure it could be written in a better, more general way.
 
Upvote 0

Forum statistics

Threads
1,216,515
Messages
6,131,111
Members
449,621
Latest member
feaugcruz

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