Combine 2 Ranges as One and copy to another worksheet
Hi Ryan
Remove the Range statement before "Union":
Union(rngSummary, rngDept).Copy Destination:=Sheets("Sheet2").Range("A5")
Regards,
Per
"RyanH" skrev i meddelelsen
...
I have two different ranges that I want to combine as one, copy then paste
to
another worksheet. My current code copies the Range("A3:T" & lngLastRow),
why?
I want to leave out the columns between Col.K and Col.T.
Dim CopyPasteRanges()
Dim lngLastRow As Long
Dim rngSummary As Range
Dim rngDept as Range
lngLastRow = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
Set rngSummary = Sheets("Sheet1").Range("A3:K" & lngLastRow)
Set rngDept = Sheets("Sheet1").Range("T3:T" & lngLastRow))
' copy entire summary and dept column to dept
Range(Union(rngSummary, rngDept)).Copy
Destination:=Sheets("Sheet2").Range("A5")
End Sub
--
Cheers,
Ryan
|