none
....

Semua Balasan

  • $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.


    \_(ツ)_/


    • Diedit oleh jrv 10 Mei 2018 19:40
    10 Mei 2018 19:37
  • 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.


    \_(ツ)_/

    17 Mei 2018 16:42