title: How to fix Compile error: expected End Sub?
body: <p>I am trying, when a line of information is added to one of my sheets, to automatically add that line to a different sheet in the same workbook.</p>
  
  <p>I found this code and tweaked it a little:</p>
  
  <pre><code>Sub addrow()
  
  Public Sub worksheet_change(ByVal target As Range)
  
      Set sourcebook = ThisWorkbook
      Set sourcesheet = sourcebook.Worksheets("sheet1")
  
      Set targetbook = ThisWorkbook
      Set targetsheet = targetbook.Worksheets("sheet10")
  
      If sourcesheet.Cells(198, 16).Value = "Auto" Or _
          sourcesheet.Cells(198, 16).Value = "Connect" Or _
          sourcesheet.Cells(198, 16).Value = "Multiple*" Or _
          sourcesheet.Cells(198, 16).Value = "Property" Or _
          sourcesheet.Cells(198, 16).Value = "Umbrella" Or _
          sourcesheet.Cells(198, 16).Value = "WC" Then
          GoTo link
      Else
          GoTo insertion
      End If
  
      insertion: targetsheet.Activate
      ActiveSheet.Rows(198).EntireRow.Insert
  
      sourcesheet.Activate
  
  link:
      'targetsheet.Cells(194, targetsheet.Range("initial response").Column) = sourcesheet.Cells(198, 16).Value
      targetsheet.Cells(194, 16) = sourcesheet.Cells(198, 16).Value
  
      targetsheet.Cells(194, 16) = sourcesheet.Cells(198, 16).Value
  
  End Sub
  </code></pre>
  
  <p>I get the error message "Compile Error: Expected End Sub" and it highlights that first line of code- Sub addrow(). When I try taking this line out, VBA requires me to create a new macro when I try and run it, which then adds that line back in, and I am back to square one.</p>