(Solved) – Match value in another sheet and copy data to current sheet


I have two worksheets. When a value is entered in column 2 of Sheet2, I need to find the value in column C of Sheet1, then copy another value from the same row where the value matched to a column 3 in Sheet2. So far I have this code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Set Sheet1 = Worksheets("Sheet2")
    Set Sheet2 = Worksheets("Sheet1")
    If Target.Column = 2 Then
        rowNumber = Sheet1.Range("C:C").Find(What:=Target.Value, LookIn:=xlValues).Row
        If Not rowNumber Is Nothing Then
            Cells(rowNumber, 3).Value = Sheet1.Range(rowNumber, 1).Value
        End If
    End If
End Sub  

However, nothing happens when I use this code. What am I doing wrong?

Leave a Reply

Your email address will not be published. Required fields are marked *