hello guys
I hope some body help to write macro the idea is when I write in cell value "e5" in sheet " invoice" based on cell value in column b in sheet "data then bring all of data in cells value in G5 & E8 and the rests of data from row 16 in sheet" invoice" I put the expected result in sheet "invoice"
this my try to write macro may be see this is not logic honestly I 'm beginner in vba but I try learning how write the code
Code
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("e5")) Is Nothing Then
Dim ws As Worksheet
lr = Cells(Rows.Count, 9).End(xlUp).Row
Set ws = Sheets("data")
With ws
If Target.Value = .Range("b" & lr) Then
Target.Range("g5") = .Range("a" & lr)
Target.Range("e8") = .Range("b" & lr)
Target.Cells(16, "b") = .Range("c" & lr)
Target.Cells(16, "c") = .Range("d" & lr)
Target.Cells(16, "d") = .Range("e" & lr)
Target.Cells(16, "e") = .Range("f" & lr)
Target.Cells(16, "f") = .Range("g" & lr)
Target.Cells(16, "g") = .Range("h" & lr)
Target.Cells(16, "i") = .Range("f" & lr)
End If
End With
End If
End Sub
Display More