Worksheet_Change(ByVal Target As Range),Target始终等于Nothing

时间:2016-08-23 22:51:38

标签: excel-vba vba excel

提前感谢您的帮助! 我使用Worksheet_Change(ByVal Target As Range)事件 Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)事件。经过一些测试后,我意识到我的事件已触发,但参数Target始终设置为Nothing。一些代码和图片休耕。

Private pNet As Range
Private pProposedValue As Range

'EVENT HANDLERS
'--------------
Private Sub Worksheet_Change(ByVal Target As Range)
    If pProposedValue Is Nothing Then

    ElseIf pNet Is Nothing Then

    ElseIf Target Is pNet Then
        pProposedValue.Value2 = Target.Value2
        Me.Calculate
    End If
End Sub

enter image description here

1 个答案:

答案 0 :(得分:2)

Is不能检查一个范围变量是否与另一个范围变量引用相同的范围。

Target Is pNet即使引用相同的范围也会为假。