Hello everyone, I am trying to find a specific row on sheet 2 using a unique id (phone Number) and have that row replaced with the row on sheet 1 which has the same unique id (phone number). The reason this is complicated is because (sheet 1) is the filtered results for certain conditions of sheet 2 that I have copied to a new sheet using VBA.
I would like to click a button to replace the changed data from sheet 1 So the rows are not the same on both sheets. I am able to find which rows of sheet 1, are the rows on sheet 2 using phone numbers as a unique identifier (=Match(H2,Sheet2!J;J,0). But i cannot code in vba to say "replace this row (=Match(H2, Sheet2!J:J,0) on sheet 2, with the actual row from sheet 1.
The format of the columns A:V are the same on both sheets. I will also need this to loop for all values of column "H:H" (Phone Numbers). This is the only unique identifier for the columns. My list will grow on the sheet, so I need it to be example to loop up to 5000 rows (if there is a value in it).
I have basic VBA skills and I need your help! I found this code and it looks promising.
"Follow Up Call List" = Sheet 1
"Leads" = Sheet 2
I would like to click a button to replace the changed data from sheet 1 So the rows are not the same on both sheets. I am able to find which rows of sheet 1, are the rows on sheet 2 using phone numbers as a unique identifier (=Match(H2,Sheet2!J;J,0). But i cannot code in vba to say "replace this row (=Match(H2, Sheet2!J:J,0) on sheet 2, with the actual row from sheet 1.
The format of the columns A:V are the same on both sheets. I will also need this to loop for all values of column "H:H" (Phone Numbers). This is the only unique identifier for the columns. My list will grow on the sheet, so I need it to be example to loop up to 5000 rows (if there is a value in it).
I have basic VBA skills and I need your help! I found this code and it looks promising.
"Follow Up Call List" = Sheet 1
"Leads" = Sheet 2
Code:
Option Explicit
Sub ReplaceData()
Dim lastRw1, lastRw2, nxtRw, m
'Determine last row with data, Sheet1
lastRw1 = Sheets("Leads").Range("H" & Rows.Count).End(xlUp).row
'Determine last row with data, Sheet2
lastRw2 = Sheets("Call List Follow Up").Range("H" & Rows.Count).End(xlUp).row
'Loop through Sheet 2, Column H
For nxtRw = 2 To lastRw2
'Search Sheet1 Column H for value from Sheet 2
With Sheets("Leads").Range("H2:H" & lastRw1)
Set m = .Find(Sheets("Call List Follow Up").Range("H" & nxtRw), lookat:=xlWhole)
'Copy Sheet2 row if match is found
If Not m Is Nothing Then
Sheets("Call List Follow Up").Range("H" & nxtRw).EntireRow.Copy _
Sheets("Leads").Range("H" & m.row)
End If
End With
Next
End Sub