Copy\paste [Closed]

Registration date
Monday March 7, 2016
Last seen
May 20, 2016

Please help with below query

Have 2 worksheets in same workbook and below macro is extracting data from other sheet based on firstname and lastname match.

Need help in modiying code -to copy/paste in master sheet(Contacts) for anychanges done in ( extracted data.

if worksheet change event used ,it removes filled in data from mastersheet(Contacts) as first name and lastname is deleted from ( column 4 and 5

Thank you for assisting in advance

Sub CopyBasedonSheet1() 'macro to pullinfo from data into contacts

Dim i As Long
Dim j As Long

Sheet4LastRow = Worksheets("4. Mobile").Range("D" & Rows.Count).End(xlUp).Row
sheet7LastRow = Worksheets("Contacts").Range("A" & Rows.Count).End(xlUp).Row

For j = 1 To Sheet4LastRow
For i = 1 To sheet7LastRow
If Worksheets("4. Mobile").Cells(j, 4).Value = Worksheets("Contacts").Cells(i, 1).Value _
And Worksheets("4. Mobile").Cells(j, 5).Value = Worksheets("Contacts").Cells(i, 2).Value Then
Worksheets("4. Mobile").Cells(j, 1).Value = Worksheets("Contacts").Cells(i, 3).Value
Worksheets("4. Mobile").Cells(j, 3).Value = Worksheets("Contacts").Cells(i, 4).Value
Worksheets("4. Mobile").Cells(j, 6).Value = Worksheets("Contacts").Cells(i, 5).Value
Worksheets("4. Mobile").Cells(j, 7).Value = Worksheets("Contacts").Cells(i, 6).Value
Worksheets("4. Mobile").Cells(j, 8).Value = Worksheets("Contacts").Cells(i, 8).Value

End If
Next i
Next j
End Sub

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!