Reputation: 55
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)
There are two workbooks, I am copying from wbsource.Worksheets(1)
to wb1.ws
The argument is - if column L&row has a "Yes" then ... E.g. if L5 equals Yes, then copy A5:L5 and paste in the first empty row in 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
Upvotes: 0
Views: 2812
Reputation: 7735
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
Upvotes: 2