title: VBA: Getting run-time 1004: Method 'Range' of object '_Worksheet' failed
body: <p>I am assigning a worksheet to a variable to make it easier to work with.  All other actions I take on this object (compare and writes) work, but I can't get it to put a border around a range.  It gives me the 1004 error for Range method failed.  What am I doing wrong here?</p>
  
  <p>Code in question (the last line is where the debugger triggers):</p>
  
  <pre><code>Dim destRow As Range
      Dim lastRow As Long
      Dim target As Worksheet
      Dim listSize As Long
  
      listSize = Me.FeatureNumber_ListBox.listCount
      Set target = ActiveWorkbook.Worksheets("mySheet")
      lastRow = target.Cells(Rows.Count, "A").End(xlUp).Row + 1
  
      ' put borders around whole row
      target.Range(Cells(lastRow, 1), Cells(lastRow, 19)).Borders.LineStyle = xlContinuous
  </code></pre>
  
  <p>Thanks</p>