简体   繁体   English

Excel VBA复制/粘贴(不带剪贴板)定义范围

[英]Excel VBA Copy/Paste Without clipboard Define Range

Sorry if this had been discussed already, I am struggling with the syntax of the ranges that I need to copy and paste. 抱歉,如果已经讨论过这个问题,那么我将无法复制和粘贴范围的语法。 I am trying to do so without using the clipboard and found out that I could do it with .Value = .Value ( Excel VBA Copy and Paste (without using Copy+Paste functions) on empty row ) 我尝试不使用剪贴板而这样做,发现我可以使用.Value = .Value在空行上执行Excel VBA复制和粘贴(不使用Copy + Paste函数)来完成此操作

There are two workbooks, I am copying from wbsource.Worksheets(1) to wb1.ws 有两个工作簿,我正在从wbsource.Worksheets(1)复制到wb1.ws

The argument is - if column L&row has a "Yes" then ... Eg if L5 equals Yes, then copy A5:L5 and paste in the first empty row in wb1.ws. 参数为-如果L&row列的值为“是”,则...例如,如果L5等于“是” ,则复制A5:L5并粘贴到wb1.ws中的第一行。

Part of my code is 我的代码的一部分是

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

I would really appreciate it if you could help me with the syntax of this 如果您可以通过此语法帮助我,我将不胜感激

I believe the following should work for you: 我相信以下对您有用:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM