我在这里发现这个VBA代码效果很好.我希望代码可以在工作簿中的其他工作表上工作.代码在Sheet 1中运行良好,但我希望代码也适用于Sheet 2,Sheet 3等.我尝试从Sheet 1模块中复制代码并将其粘贴到Sheet 2,Sheet 3等中,以查看代码是否有效.代码并没有像我预期的那样工作.我想我需要对标准模块代码做一些事情,这样代码才能正常工作.
表1模块
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) <> c.Text Then
'if so (they're not equal), remember this cell
c.ClearComments
c.AddComment …Run Code Online (Sandbox Code Playgroud)