VBA-将数据添加到下一个空行

时间:2017-05-11 01:42:44

标签: vba excel-vba excel

我已经编写了下面的宏来将数据从一个工作表传输到另一个工作表。我希望将新数据传输到空行,但它会一直覆盖行

  Worksheets("sheet1").Select
     Worksheets("sheet1").Range("a1").Select
     RowCount = Worksheets("sheet1").Range("A1").CurrentRegion.Rows.Count
     With Worksheets("Sheet1").Range("A1")
     .Offset(RowCount, 0) = workOrderDescription

1 个答案:

答案 0 :(得分:1)

尝试以下代码:

With Workbooks("Your_WorkbookmName").Worksheets("sheet1")
    RowCount = .Cells(.Rows.Count, "A").End(xlUp).Row ' <-- get last row in column "A"
    .Range("A" & RowCount + 1) = workOrderDescription
End With