My translation code is not working as I wanted... It should do the Propercase only in the first word of the cell, but it is doing the propercase in all of the words in the cell.
Any ideas on how to make it translate and only use propercase on the first word in the activecell?
Here is the code:
Sub traducaobeta2()
Dim translate As Object 'scritping.Dictionary
Set translate = CreateObject("Scripting.Dictionary")
translate("cadeira") = "chair"
translate("cadeira,") = "chair"
translate("cadeiras") = "chairs"
translate("criado mudo") = "night stand"
translate("criado-mudo") = "night stand"
translate("mesa") = "table"
translate("mesas") = "tables"
translate("e") = "and"
' the list goes on...
Dim Words As Variant
Dim I As Integer
Words = Split(LCase(activecell.Value))
For I = LBound(Words) To UBound(Words)
If translate(Words(I)) <> "" Then Words(I) = translate(Words(I))
Next
activecell.Value = Join(Words)
For Each x In activecell
x.Value = Application.Proper(x.Value)
Next
activecell.Offset(0, 1).Select
End Sub
Just make the first letter a captial:
ActiveCell.value = UCase$(Left$(ActiveCell.value, 1)) & Right$(ActiveCell.value, Len(ActiveCell.value) - 1)
Could also use a With
block to save typing:
With ActiveCell
.value = UCase$(Left$(.value, 1)) & Right$(.value, Len(.value) - 1)
End With