.... RRS feed

  • Question

  • ....

    • Edited by fierymadness Thursday, May 17, 2018 8:35 PM
    • Moved by jrv Thursday, May 17, 2018 8:46 PM abandoned post
    Thursday, May 10, 2018 7:23 PM

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)

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


    Thursday, May 17, 2018 4:42 PM