Hi delnaja ... try this:
Sub UpdateFromWeeklyChangeSheet()
Dim i As Integer
Dim j As Integer
Dim MasterRowCount As Integer
Dim UpdateRowCount As Integer
Dim MasterID As String
Dim UpdateID As String
Dim booMatchFound As Boolean
'i've name the sheets "Master" and "Updates".
'for simplicity, I've assumed they're in the same workbook, but you can change that if you need to.
'from your desciption, I've assumed only records with changes are in the weekly sheet.
'i've also assumed there are no blank rows - it's solid data from row 1 to the last record.
'this runs through the update sheet row by row, looks to see if the ID in column A exists
'in the master sheet; if it does it replaces the record; if it doesn't it adds it to the end.
Sheets("Updates").Select
UpdateRowCount = Sheets("Updates").Range("A1").End(xlDown).Row
MasterRowCount = Sheets("Master").Range("A1").End(xlDown).Row
'cater for only 1 record in either sheet (i assume there will never be none):
If UpdateRowCount = 65536 Then UpdateRowCount = 1
If MasterRowCount = 65536 Then MasterRowCount = 1
For i = 1 To UpdateRowCount
UpdateID = Trim(CStr(Sheets("Updates").Range("A" & i).Text))
For j = 1 To MasterRowCount
MasterID = Trim(CStr(Sheets("Master").Range("A" & j).Text))
'if a match is found, update it and get the next update record:
If MasterID = UpdateID Then
booMatchFound = True
Sheets("Updates").Range("A" & i).EntireRow.Copy Destination:=Sheets("Master").Range("A" & j)
GoTo GetNextUpdateRow
End If
'if at the end of the master list and no match found, add to the end,
'increment the master row count, and get the next update row:
If j = MasterRowCount And booMatchFound = False Then
Sheets("Updates").Range("A" & i).EntireRow.Copy Destination:=Sheets("Master").Range("A" & j)
MasterRowCount = MasterRowCount + 1
GoTo GetNextUpdateRow
End If
Next j
GetNextUpdateRow:
booMatchFound = False
Next i
End Sub
Hope that helps.
MM
Bookmarks