title: Using Powershell to Append a table to the end of an Excel File (The Last Row)
body: <p>I've written a Powershell script that copies a table from Microsoft Word and pastes them to an excel document.  I want to append it after the last used row in column A. </p>
  
  <p>I got this code so far: </p>
  
  <pre><code>$Excel = New-Object -ComObject Excel.Application
  
  $Excel.Visible = $True
  
  $ExcelWordBook = $Excel.Workbooks.Open($ExcelPath)
  
  $ExcelWorkSheet = $Excel.WorkSheets.item("Sheet1")
  
  $ExcelWorkSheet.activate()
  </code></pre>
  
  <p>This is where I get confused, I want to be able to find the last row that is used in the Excel WorkSheet.</p>
  
  <pre><code>$lastRow = $ExcelWorkSheet.UsedRange.rows("A").count
  
  $nextRow = $lastRow + 1
  
  $ExcelWorkSheet.Range("A$nextRow").Select
  
  $ExcelWorkSheet.Paste()  
  </code></pre>
  
  <hr>
  
  <p><p>I feel like I'm so close after this. I was trying to use the UsedRange property in the Office Interlop to determine the last row in the Excel WorkSheet. (<a href="http://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.worksheet.usedrange(v=vs.80).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.worksheet.usedrange(v=vs.80).aspx</a>) Any ideas?</p>