Text replacement Macro

I wrote a massive text replacement macro but it's very slow. my system info "Processor Intel(R) Core(TM) i7-2630QM CPU @ 2.00GHz, 2001 Mhz, 4 Core(s), 8 Logical Processor(s)". How can I optimize the VBA and make it replace the text faster.

Parents
No Data
Reply
    • Dim Tc(16)
      For x = 1 To 16

      'number input from the user
      Tc(x) = InputBox("Please ensure you enter the correct number" : " & x)

      Next x

      For i = 1 To 16

      Dim txtFindCTcHome As Variant
      txtFindCTcHome = "CTcH" & i & "#"
      Dim txtCTcHReplacer As Variant
      txtCTcHReplacer = aFh(Tc(i))
      Dim txtReplaceCTcHome As String
      txtReplaceCTcHome = UCase(txtCTcHReplacer)


      Dim txtFindCTcAway As Variant
      txtFindCTcAway = "CTcA" & i & "#"
      Dim txtReplacerCTcAway As Variant
      txtReplacerCTcAway = aFA(Tc(i))
      Dim txtReplaceCTcAway As String
      txtReplaceCTcAway = UCase(txtReplacerCTcAway)


      Dim txtFindTcHome As Variant
      txtFindTcHome = "TcH" & i & "#"
      Dim txtReplaceTcHome As Variant
      txtReplaceTcHome = aFh(Tc(i))


      Dim txtFindTcAway As Variant
      txtFindTcAway = "TcA" & i & "#"
      Dim txtReplaceTcAway As Variant
      txtReplaceTcAway = aFA(Tc(i))


      Dim txtFindNTc As Variant
      txtFindNTc = "Nt" & i & "#"
      Dim txtReplaceNTc As Variant
      If Tc(i) < 10 Then
      txtReplaceNTc = "0" & Tc(i)
      Else
      txtReplaceNTc = Tc(i)
      End If



      Dim d As Document
      Dim p As Page

      'the d as document makes the code run on all the pages the keyword appears

      For Each d In Documents
      For Each p In d.Pages

      '-------------Activator--------------------
      p.TextReplace txtFindCTcHome, txtReplaceCTcHome, True, False
      p.TextReplace txtFindCTcAway, txtReplaceCTcAway, True, False
      p.TextReplace txtFindTcHome, txtReplaceTcHome, True, False
      p.TextReplace txtFindTcAway, txtReplaceTcAway, True, False
      p.TextReplace txtFindNTc, txtReplaceNTc, True, False

      Next p
      Next d

      Next i
      Thanks
Children
No Data