Hi all,
I have this code (credits to @Fluff13) that replaces values on one worksheet with values on another (using a lookup value that is consistent across the two worksheets).
Basically, I am using this to translate content across multiple languages, where the lookup value = the language. See here for the initial thread.
Sub ReplaceContentString()
Dim r As Long, c As Long
Dim Ws As Worksheet
Set Ws = Sheets("Translation")
With Sheets("Translator").Range("D9:D100")
For c = 3 To 94
.Replace Ws.Cells(2, c), "=xxx" & Ws.Cells(2, c), xlWhole, , False, , False, False
With .SpecialCells(xlFormulas, xlErrors).Offset(, 1)
For r = 3 To 102
.Replace Ws.Cells(r, 2), Ws.Cells(r, c), xlPart, , False, , False, False
Next r
End With
.Replace "=xxx" & Ws.Cells(2, c), Ws.Cells(2, c), xlWhole, , False, , False, False
Next c
End With
End Sub
If I use this with single values, e.g. replace "apple" with "Apfel", it works fine, however, as soon as I add whole sentences to replace, I get a "type mismatch" error on line
.Replace Ws.Cells(r, 2), Ws.Cells(r, c), xlPart, , False, , False, False
My assumption is that .replace cannot handle the replacement if the cell exceeds a certain character count.
My question is: is there a way to tweak this to allow me to replace full sentences, ideally lifting re character restriction completely?
Hope this works somehow?
Thanks all!
Bookmarks