Hello
I need help from experts to help me how adapt this code for my requirements .
I have sheet1 is target and contains cell B2 should fill the name and the others data start from A4:G , the row4 is the headers . the name in cell B2 should match with column G for DATA sheet (DATA sheet start from A1: G , the row1 is header ) if they are matched ,then should copy data without any formatting form DATA sheet to target sheet(sheet1) from row 5 , but shouldn't copy to the bottom , just replace data .
I need help from experts to help me how adapt this code for my requirements .
I have sheet1 is target and contains cell B2 should fill the name and the others data start from A4:G , the row4 is the headers . the name in cell B2 should match with column G for DATA sheet (DATA sheet start from A1: G , the row1 is header ) if they are matched ,then should copy data without any formatting form DATA sheet to target sheet(sheet1) from row 5 , but shouldn't copy to the bottom , just replace data .
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Fnd As Range
Dim sh As Worksheet
Set sh = Sheets("DATA")
If Target.Count > 1 Then Exit Sub
If Target.Address(0, 0) = "B2" And Target.Value <> "" Then
Set Fnd = sh.Range("G:G").Find(Target.Value, , , xlWhole, , , False, , False)
If Not Fnd Is Nothing Then
sh.Cells.EntireRow.Copy Target.Cells(Rows.Count, 1).End(xlUp).Offset(1)
Else
MsgBox Target.Value & " not found"
End If
End If
End Sub
thanks