Combine 2 Ranges as One and copy to another worksheet

R

RyanH

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
 
P

Per Jessen

Hi Ryan

Remove the Range statement before "Union":

Union(rngSummary, rngDept).Copy Destination:=Sheets("Sheet2").Range("A5")

Regards,
Per
 
R

RyanH

Thanks Per! Thats what I needed.
--
Cheers,
Ryan


Per Jessen said:
Hi Ryan

Remove the Range statement before "Union":

Union(rngSummary, rngDept).Copy Destination:=Sheets("Sheet2").Range("A5")

Regards,
Per
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top