title: Update Table from Reference worksheet
body: <p>I have a master table that I need clients to be able to update using a worksheet where they will edit a "status", "notes" and "date" column for each target they have set,and then click a button to update the master table.</p>
  
  <p>Both the master table and the worksheet have a target ID value that I intended to use for matching. I would like to be able to loop through the master database and find if there is a matching target ID in the "update" table, and if there is I need to update three columns in the master table from the matching row in the "update" table. I tried writing this loop in VBA but I am stuck on the correct code (I'm very new to VBA).</p>
  
  <p>Here is the code I have:</p>
  
  <pre><code>Sub Button4_Click()
  Dim i As Integer
  Dim tbl As ListObject
  Set tbl = Sheets("Master").ListObjects("MasterTable")
  
  For i = 2 To tbl.Range.Rows.Count
  
  If Sheets("Master").Cells(i, 1) = Sheets("Data Update").Cells(i, 1) Then
  Range(Sheets("Data Update").Cells(i, 9), Sheets("Data Update").Cells(i, 11)).Copy
  Range(Sheets("Master").Cells(i, 9), Sheets("Master").Cells(i, 11)).PasteSpecial xlPasteValues
  
  ElseIf Sheets("Master").Cells(i + 1, 1) = Sheets("Data Update").Cells(i, 1) Then
  Range(Sheets("Data Update").Cells(i, 9), Sheets("Data Update").Cells(i, 11)).Copy
  Range(Sheets("Master").Cells(i, 9), Sheets("Master").Cells(i, 11)).PasteSpecial xlPasteValues
  
  End If
  Next i
  
  End Sub
  </code></pre>
  
  <p>It works only if the target ID in the "update" table is in the same row as the  target ID in the "master" table. So, if target ID #1 is in row 1 in both tables it will match, if target ID #2 is in row 2 in both tables it will match, etc. But it won't find the target ID if its out of order and it will stop of the target IDs are not in sequential order</p>