Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here's another way, which, too, depends on functions from the web site;
I didn't take the trouble to declare variables, but of course you should: Sub abtest1() Dim arr1() ReDim arr1(1 To 3, 1 To 1) With ThisWorkbook.Worksheets(1) arr1 = .Range(.Cells(2, 1), .Cells(4, 2)).Value arr2 = .Range(.Cells(2, 6), .Cells(4, 6)).Value End With 'Add a second column of empty values to arr1 ReDim Preserve arr1(1 To 3, 1 To 2) 'Replace the second column of arr1 with the values from arr2 ReplaceSubArray arr1, arr2, 1, 2 End Sub If the code is in a general module I would replace the 3rd thru 6th lines with the following, which better suits my taste: Set rng = ThisWorkbook.Worksheets(1).Range("A1") arr1 = Range(rng(2, 1), rng(4, 2)) arr2 = Range(rng(2, 6), rng(4, 6)) I'm not a fan of the Cells Property, and in addition, the above avoids the need for qualification if Worksheets(1) is not the active sheet. Alan Beban |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I assign range to variant and use | Excel Discussion (Misc queries) | |||
Assigning range to variant | Excel Programming | |||
Assigning range to variant | Excel Programming | |||
How to define a Range with variant? | Excel Programming | |||
Best way to paste a variant array into a range? | Excel Programming |