none
.... RRS feed

All replies

  • $worksheet.UsedRange.Rows.Count + 1

    Gets the next available row index.

    Use Range.Paste()

    Also we can avoid past using CopyTo.  Copies a range to a range.  It can also copy between sheets and workbooks.

    Paste is mostly obsolete except when copying from non-Excel sources.


    \_(ツ)_/


    • Edited by jrv Thursday, May 10, 2018 7:40 PM
    Thursday, May 10, 2018 7:37 PM
  • Please do not post duplicate questions when you are unsatisfied with an answer.

    For critical Excel programming issues you should post in the Excel Developers forum.

    Your code is not pasting into the range end.  You want to target the last row and first column of the target sheet.  The target range should be one cell  - the upper left corner of the desired region.

    $r = $xl.Worksheets[1].Cells.Item($xl.Worksheets[1].UsedRange.Rows.Count+1,1)
    $xl.Worksheets[1].Paste($r)

    This gets the first cell after the UsedRange and pastes the new data from there.


    \_(ツ)_/

    Thursday, May 17, 2018 4:42 PM