David Bell
David Bell

Reputation: 505

Worksheet_Change(ByVal Target As Range), Target always equals Nothing

thanks for all your help in advance!
I am using the Worksheet_Change(ByVal Target As Range) event NOT the Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) event. After some testing I realized that my event fires but the argument Target is always set to Nothing. Some code and a picture fallows.

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

Upvotes: 0

Views: 822

Answers (1)

Tim Williams
Tim Williams

Reputation: 166306

Is doesn't work for checking if one range variable refers to the same range as another range variable.

Target Is pNet will be false even if they refer to the same range.

Upvotes: 2

Related Questions