【问题标题】:Excel VBA Copy/Paste Without clipboard Define RangeExcel VBA复制/粘贴没有剪贴板定义范围
【发布时间】:2018-02-22 20:53:00
【问题描述】:

很抱歉,如果这已经讨论过了,我正在为需要复制和粘贴的范围的语法而苦苦挣扎。我试图在不使用剪贴板的情况下这样做,并发现我可以使用 .Value = .Value (Excel VBA Copy and Paste (without using Copy+Paste functions) on empty row) 来做到这一点

有两个工作簿,我从wbsource.Worksheets(1)复制到wb1.ws

参数是 - 如果列 L&row 有一个 "Yes" 则 ... 例如如果 L5 等于 Yes,则复制 A5:L5 并粘贴到 wb1.ws 的第一个空行中。

我的部分代码是

If .Cells(rw, 12) = "Yes" Then
    Dim lastrw As Long
    lastrw = ws.Cells(ws.Rows.Count, 1).End(xlUp).Offset(1, 0).Row
    wbsource.Worksheets(1).???? = ws.Range("A" & lastrw).Value
End If

如果你能帮助我了解这个语法,我将不胜感激

【问题讨论】:

  • 应该是destination.Value = source.Value,其中destinationsource 是您选择的范围。所以你需要左右翻转你的代码。
  • `ws.Range("A" & lastrw & ":L" & lastrw).Value=wbsource.sheets(1).range("A" & rw & ":L" & rw ).值

标签: excel vba


【解决方案1】:

我相信以下内容应该适合您:

If wbsource.Worksheets(1).Cells(rw, 12) = "Yes" Then
    Dim lastrw As Long
    lastrw = ws.Cells(ws.Rows.Count, 1).End(xlUp).Offset(1, 0).Row
    ws.Range("A" & lastrw & ":L" & lastrw).Value = wbsource.Worksheets(1).Range("A" & rw & ":L" & rw).Value
End If

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-29
    • 1970-01-01
    • 1970-01-01
    • 2016-08-05
    • 1970-01-01
    • 1970-01-01
    • 2015-10-06
    相关资源
    最近更新 更多