fboehlandt
10-07-2008, 08:54 AM
Hi everyone,
I would like to create a new joint range from two discontinuous ranges on the same worksheet. So far I have the following:
Sub Test2()
Dim wb As Workbook
Dim ws1, ws2 As Worksheet
Dim rng1a, rng1b, rng_union As Range
Set wb = ThisWorkbook
Set ws1 = wb.Worksheets("testsheet_roi2")
Set ws2 = wb.Worksheets("result")
ws1.Select
Set rng1 = Range(Cells(2, 2), Cells(32, 2))
Set rng2 = Range(Cells(2, 4), Cells(32, 4))
Set rng_union = Union(rng1, rng2)
ws2.Select
Range(Cells(2, 2), Cells(63, 2)).Value = rng_union.Value
End Sub
this only display rng1 instead of both ranges. What am I doing wrong?
I would like to create a new joint range from two discontinuous ranges on the same worksheet. So far I have the following:
Sub Test2()
Dim wb As Workbook
Dim ws1, ws2 As Worksheet
Dim rng1a, rng1b, rng_union As Range
Set wb = ThisWorkbook
Set ws1 = wb.Worksheets("testsheet_roi2")
Set ws2 = wb.Worksheets("result")
ws1.Select
Set rng1 = Range(Cells(2, 2), Cells(32, 2))
Set rng2 = Range(Cells(2, 4), Cells(32, 4))
Set rng_union = Union(rng1, rng2)
ws2.Select
Range(Cells(2, 2), Cells(63, 2)).Value = rng_union.Value
End Sub
this only display rng1 instead of both ranges. What am I doing wrong?