• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA Translator

JacobP

New Member
Hey everyone! Peter here and I need some help with my code.

I have a code that checks text values in my worksheets and translates them to their English equivalent.

I would like to add a method to select chart titles on each worksheet and translate it to English as well. Below is my current code. Your help is greatly appreciated.

Code:
Sub Modified_Translator()


   Const lang1 As Long = 1
   Const lang2 As Long = 2
   Dim arr1    As Variant
   Dim arr2    As Variant
   Dim i       As Long
   Dim lr      As Long
   Dim ws      As Worksheet
   Dim Chrt    As ChartObject
  
   With ActiveWorkbook.Worksheets("Words")
      lr = .Cells(.Rows.Count, 1).End(xlUp).Row
      arr1 = .Range(.Cells(2, lang1), .Cells(lr, lang1))
      arr2 = .Range(.Cells(2, lang2), .Cells(lr, lang2))
   End With
  
   For Each ws In ActiveWorkbook.Worksheets
      If ws.Name <> "Words" Then
         With ws
            .UsedRange.Value = .UsedRange.Value
            For i = 1 To lr - 1
               .Cells.Replace what:=arr1(i, 1), replacement:=arr2(i, 1), LookAt:=xlWhole, _
                              SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
                              ReplaceFormat:=False
                                              
            Next i
         End With
      End If
   Next ws

End Sub
 
Back
Top