Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Combine 2 Ranges as One and copy to another worksheet
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Combine 2 Ranges as One and copy to another worksheet
Hello Ryan,
Ron de Bruin has some great stuff along the lines of what you are trying to do, see: Copy/Paste/Merge examples. http://www.rondebruin.nl/tips.htm HTH--Lonnie M. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Combine 2 Ranges as One and copy to another worksheet
Thanks Per! Thats what I needed.
-- Cheers, Ryan "Per Jessen" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
trying to copy a worksheet containing named ranges to anotherworksheet | Excel Worksheet Functions | |||
Combine multiple ranges into one worksheet | Excel Discussion (Misc queries) | |||
Copy Worksheet with Named Ranges | Excel Programming | |||
Copy worksheet ranges from One Workbook to another from | Excel Worksheet Functions | |||
Copy Worksheet plus ranges | Excel Programming |