Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here is another macro for you to consider (less looping)...
Sub CombineRanges() Dim X As Long, Rng1 As Range, Rng2 As Range, StartCell As Range Set Rng1 = Range("Range1") Set Rng2 = Range("Range2") Set StartCell = Range("A1") Rng2.Copy StartCell.Offset(, Rng1.Columns.Count).Resize( _ Rng1.Rows.Count * Rng2.Rows.Count, Rng2.Columns.Count) For X = 1 To Rng2.Rows.Count * Rng2.Rows.Count Rng1.Rows(X).Copy StartCell.Offset((X - 1) * _ Rng2.Rows.Count).Resize(Rng2.Rows.Count) Next End Sub Like Jacob's macro, I'm assuming you named the two ranges that you want to combine as indicated. Of course, you can set specific ranges, rather than named ranges, in the two Set statements if desired. -- Rick (MVP - Excel) "Ciprian" wrote in message ... Hi, I have two different ranges with different numbers of rows and columns. I have to combine in a single range each row from the first range with each row from the second range. I provide hereunder an example. Any idea? Thank you! Range 1 A B C D E F G H I J K L Range 2 1 2 3 4 5 6 7 8 Result A B C 1 2 3 4 A B C 5 6 7 8 D E F 1 2 3 4 D E F 5 6 7 8 G H I 1 2 3 4 G H I 5 6 7 8 J K L 1 2 3 4 J K L 5 6 7 8 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Not just remove dup rows but combine columns | Excel Worksheet Functions | |||
need a macro to combine rows, columns | Excel Programming | |||
Combine multiple columns into two long columns, Repeating rows in first column | Excel Discussion (Misc queries) | |||
Combine multiple columns into two long columns, Repeating rows in first column | Excel Discussion (Misc queries) | |||
Combine 2 columns of numbers (A+B=C) | Excel Programming |