-
Copy between sheets
Hello all,
I need to set a range to copy data in between sheets
I have tried
[vba]set rng = Sheets(1).Range("A" & i ":D" & j)
set rng2 = Sheets(2).Range("A" & i ":D" & j)
rng.copy rng[/vba]
and
[vba]set rng = sheets(1).range(cells(i,1),cells(j,4))
set rng2 = sheets(2).range(cells(i,1),cells(j,4))
rng.copy rng[/vba]
but none of them works
any help would be appreciated, thanks
-
copyt,
Looks good to me (only thing i see is range.copy rng should be just rng.copy)
This works for me:
[VBA]Sub test()
Dim rng As Range
Dim i As Integer
Dim j As Integer
i = 1
j = 10
Set rng = Sheets(1).Range("D" & i & ":D" & j)
rng.Copy
Sheet1.Cells(1, 5).Select
ActiveCell.PasteSpecial
End Sub[/VBA]
-
@ CodeNinja Thank you very much. Your code also works for me. :bow::bow:
-
Hi Copyt,
I hate to be the bearer of bad news, and you're going to kick yourself, but your code actually worked. The code
[VBA]rng.copy rng [/VBA]
will copy the range onto itself. All you needed was to add a "2" to get
[VBA]rng.copy rng2 [/VBA]
Life's like that. :banghead: