Это выглядит неправильно
Set Sheet1 = Worksheets("Sheet2")
Set Sheet2 = Worksheets("Sheet1")
Если совпадений нет, вы не можете получить номер строки из диапазона Nothing.
rowNumber = Sheet1.Range("C:C").Find(What:=Target.Value, LookIn:=xlValues).Row
Вероятно, вы хотите обновить строку Target.row
не rowNumber
, а Range(rowNumber,1)
должно быть Cells(rowNumber,1)
Cells(rowNumber, 3).Value = Sheet1.Range(rowNumber, 1).Value
Попробуйте
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column <> 2 Then Exit Sub
Dim wb As Workbook, Sheet1 As Worksheet, Sheet2 As Worksheet
Dim rng As Range, rowNumber As Long
Set wb = ThisWorkbook
Set Sheet1 = wb.Worksheets("Sheet1")
Set Sheet2 = wb.Worksheets("Sheet2")
Set rng = Sheet1.Range("C:C").Find( _
What:=Target.Value, _
LookIn:=xlValues, _
LookAt:=xlWhole)
If Not rng Is Nothing Then
rowNumber = rng.Row
Sheet2.Cells(Target.Row, 3).Value = Sheet1.Cells(rowNumber, 1).Value
End If
End Sub