hello
i have this code it supposing bring the values on col b,e,f baesd on cell value in col d if i rewritng the same company then bring values in col b,e,f
but the code not works
Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Long
Dim rng As Range
Dim val As Variant
If Target.CountLarge > 1 Then Exit Sub
If (Target.Column > 1) Or (Target.Row <= 2) Then Exit Sub
If Target.Value = "" Then Exit Sub
r = Target.Row
Set rng = Range("b4:f" & r - 1)
On Error GoTo err_exit
val = Application.VLookup(Target.Value, rng, 6, 0)
val = Application.VLookup(Target.Value, rng, 5, 0)
val = Application.VLookup(Target.Value, rng, 2, 0)
If IsError(val) Then Exit Sub
If Cells(r, "e") & Cells(r, "f") & Cells(r, "b") = "" Then
Cells(r, "e") = val
Cells(r, "f") = val
Cells(r, "b") = val
End If
Exit Sub
err_exit:
Err.Clear
End Sub