title: VBA to add cell values on match between two cells
body: <p>I have the following code which looks for a match between worksheet 1 column C and worksheet 2 column E, and when there is a match it will copy over the value in certain other cells on the same row. It works well, however when there is more than one match between worksheet 1 column C and worksheet 2 column E, each subsequent match is just re-writing over the original. </p>
  
  <p>How can I code it so that the first match will copy over the values, but then any subsequent matches will simply add their values, not write over them?</p>
  
  <p>Thank you in advance!</p>
  
  <pre><code> Sub OnClick()
   'Define your variables
  Dim ws1 As Worksheet, ws2 As Worksheet, cel As Range, i As Long
  
  'Assign your worksheet variables
  Set ws1 = ThisWorkbook.Sheets("PLANNER_ONGOING_DISPLAY_SHEET")
  Set ws2 = ThisWorkbook.Sheets("REPORT_DOWNLOAD")
  
      'First loop through each cell in Sheet2, column E, start at row 2 to account
      'for header row) to get the value to find in sheet1, column C.
      For Each cel In ws2.Range("E2:E" &amp; ws2.Range("E" &amp; ws2.Rows.Count).End(xlUp).Row)
  
          'Then loop through each cell in Sheet1, Column C. If you get a match, then
          'copy the value from Sheet2, Column B, cel.row to Sheet1, Column S, i row.
          For i = 2 To ws1.Range("L" &amp; ws1.Rows.Count).End(xlUp).Row
  
              If cel.Value = ws1.Cells(i, 3).Value Then
                  ws1.Cells(i, 3).Offset(, 16).Value = cel.Offset(, 3).Value
                  ws1.Cells(i, 3).Offset(, 15).Value = cel.Offset(, 4).Value
                  ws1.Cells(i, 3).Offset(, 17).Value = cel.Offset(, 7).Value
              End If
  
          Next i 'loops through every used cell in Column C for all matches
      Next cel 'loop to the next cell in Sheets2, Columns E
  
  End Sub
  </code></pre>