Jump to cells/rows in Union Range

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Jump to cells/rows in Union Range

Post by Rudi »

Hi,

r1 = Range(A1:B10)
r2 = Range(D1:E10)
rUnion = (r1,r2)

Now I want to select the following in the rUnion range by loop
A1:B1, then
D1:E1, then
A2:B2, then
D2:E2, etc...

How can I do this (if possible?)

TX
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

User avatar
HansV
Administrator
Posts: 78642
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Jump to cells/rows in Union Range

Post by HansV »

1) Why do you want to select cells in a macro?
2) If you want to do it, I wouldn't use the union but loop through the rows of r1 and r2:

Code: Select all

Sub ForRudi()
    Dim r1 As Range
    Dim r2 As Range
    Dim i As Long
    Set r1 = Range("A1:B10")
    Set r2 = Range("D1:E10")
    For i = 1 To r1.Rows.Count
        r1.Rows(i).Select
        MsgBox "Click OK to continue", vbOKOnly
        r2.Rows(i).Select
        MsgBox "Click OK to continue", vbOKOnly
    Next i
End Sub
Best wishes,
Hans

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Jump to cells/rows in Union Range

Post by Rudi »

Don't worry... I'm not selecting. That was just for the post...to explain...
Thanks. I'll get rid of the Union.
Your code does what I need. I'll be replacing select with a paste action.

:cheers:
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.