Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel VBA锁定单元赢得';不要变色_Excel_Vba - Fatal编程技术网

Excel VBA锁定单元赢得';不要变色

Excel VBA锁定单元赢得';不要变色,excel,vba,Excel,Vba,我正在做一些应该比较数据的事情。数据的一部分仅用于比较(此部分应锁定),如果另一部分中的某些内容发生更改,则更改的单元格的颜色应更改。当两边都解锁时,它工作正常。当我锁定一侧时,颜色不再改变。有人知道为什么吗 Set rngBereich = Intersect(Target, Range("N3:N3000,P3:P3000,T3:Z3000")) If Not rngBereich Is Nothing Then For Each rngArea In rngBereich.Ar

我正在做一些应该比较数据的事情。数据的一部分仅用于比较(此部分应锁定),如果另一部分中的某些内容发生更改,则更改的单元格的颜色应更改。当两边都解锁时,它工作正常。当我锁定一侧时,颜色不再改变。有人知道为什么吗

Set rngBereich = Intersect(Target, Range("N3:N3000,P3:P3000,T3:Z3000"))
  If Not rngBereich Is Nothing Then
    For Each rngArea In rngBereich.Areas
      For Each rngZelle In rngArea
        Dim str1 As String
        Dim str2 As String
        str1 = rngZelle.Value
        str2 = rngZelle.Offset(0, 20).Value

        If str1 <> str2 Then
          rngZelle.Interior.ColorIndex = 6
        Else
          rngZelle.Interior.ColorIndex = 0
        End If
      Next rngZelle
    Next rngArea
  End If
Set rngBereich=Intersect(目标,范围(“N3:N3000,P3:P3000,T3:Z3000”))
如果不是,那就什么都不是了
对于RNGBerich.区域内的每个rngArea
对于rngArea中的每个rngZelle
将str1设置为字符串
将str2设置为字符串
str1=rngZelle.值
str2=rngZelle.Offset(0,20).Value
如果是str1或str2,则
rngZelle.Interior.ColorIndex=6
其他的
rngZelle.Interior.ColorIndex=0
如果结束
下一个rngZelle
下一站
如果结束

So
rngZelle.Offset(0,20)
是锁定的单元格吗?我无法重现错误(我甚至输入了一个
Debug.Print rngZelle.Offset(0,20).Locked
来确认它确实被锁定了。是的。
rngZelle.Offset(0,20)
是被锁定的单元格。如前所述,我无法重现此错误。