title: I have a VBA code entered on Sheet 1. I want the code to work on Sheet 2. Do i just copy the code from Sheet 1 to Sheet 2?
body: <p>I found this VBA code on here that works great. I want the code to work on the other worksheets in the workbook. The code works great in Sheet 1 but I would like the code to work on Sheet 2, Sheet 3, etc. as well. I tried copying the code from the Sheet 1 Module and pasted it into Sheet 2, Sheet 3, etc. to see if the code works. The code doesn't quite work as I anticipated it. I think I need to do something with the Standard Module code so that the code will work properly.</p>
  
  <p>Sheet 1 Module</p>
  
  <pre><code>Private Sub Worksheet_Calculate()
      Dim rng As Range, c As Range
      Dim rngToColor As Range
  
      On Error GoTo ErrorHandler
  
      Application.EnableEvents = False
      'get only used part of the sheet
      Set rng = Intersect(Me.UsedRange, Me.Range("A:Z"))
      If rng Is Nothing Then GoTo ExitHere 
  
      For Each c In rng
          'check if previous value of this cell not equal to current value
          If cVals(c.Address) &lt;&gt; c.Text Then
              'if so (they're not equal), remember this cell
              c.ClearComments
              c.AddComment Text:="Changed value from '" &amp; cVals(c.Address) &amp; "' to '" &amp; c.Text &amp; "'" &amp; " on " &amp; Format(Date, "mm-dd-yyyy") &amp; " by " &amp; Environ("UserName")
              c.Interior.ColorIndex = 36
          End If
  
          'store current value of cell in dictionary (with key=cell address)
          cVals(c.Address) = c.Text
      Next c
  
  ExitHere:
      Application.EnableEvents = True
      Exit Sub
  ErrorHandler:
      Resume ExitHere
  End Sub
  </code></pre>
  
  <p>ThisWorkbook Module</p>
  
  <pre><code>Private Sub Workbook_Open()
      Application.Calculation = xlCalculationManual
      Call populateDict
      Application.Calculation = xlCalculationAutomatic
  End Sub
  </code></pre>
  
  <p>Standard Module</p>
  
  <pre><code>Public cVals As New Dictionary
  
  Sub populateDict()
      Dim rng As Range, c As Range
  
      With ThisWorkbook.Worksheets("Sheet1")
          Set rng = Intersect(.UsedRange, .Range("A:Z"))
          For Each c In rng
              cVals(c.Address) = c.Text
          Next c
          .Calculate
      End With
  
  End Sub
  </code></pre>
  
  <p>Edit: I took the standard module and revised it to:</p>
  
  <pre><code>Sub populateDict()
      Dim rng As Range, c As Range
  
      With ThisWorkbook.Worksheets("Sheet1")
          Set rng = Intersect(.UsedRange, .Range("A:Z"))
          For Each c In rng
              cVals(c.Address) = c.Text
          Next c
          .Calculate
      End With
  
      With ThisWorkbook.Worksheets("Sheet2")
          Set rng = Intersect(.UsedRange, .Range("A:Z"))
          For Each c In rng
              cVals(c.Address) = c.Text
          Next c
          .Calculate
      End With
  
  End Sub
  </code></pre>
  
  <p>this edit almost does the trick, but not sure why code isn't working correctly</p>