Range selection with R1C1

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to replicate Range("D8:F8","I8:K8").Select using R1C1 references.

Can I somehow make the Range(Cells(r,c),Cells(r,c)).Select work for a
compound range?

Thanks
 
Not too sure what exactly you want since what you want to replicate
Range("D8:F8","I8:K8").Select
is the same as
Range("D8:K8").Select
(Not a compound range???)

If you do want a compound reange then try this
union(Range("D8:F8"),Range("I8:K8")).Select
or
Union(Cells(r,c),Cells(r,c)).Select
 
If the workbook has R1C1 reference style:

[r8c4:r8c6,r8c9:r8c11].Select



--
Kind regards,

Niek Otten
Microsoft MVP - Excel


|I would like to replicate Range("D8:F8","I8:K8").Select using R1C1 references.
|
| Can I somehow make the Range(Cells(r,c),Cells(r,c)).Select work for a
| compound range?
|
| Thanks
 
But the suggestion below only has two Cells(r,c) which will allow me to
describe a range, but not a compound range. I would need four Cell
references (one for the start and end of each range) and that is what doesn't
seem to work.
thanks
 
So it is a compound range you want then... try this

union(range(cells(r1, c1), cells(r2, c2)), range(cells(r3, c3), cells(r4,
c4))).Select

It defines two ranges based on RC co-ordinates and unions those 2 ranges
together...
To see it a little more clearly you could do this

dim rng1 as range
dim rng2 as range

set rng1 = range(cells(r1, c1), cells(r2, c2))
set rng2 = range(cells(r3, c3), cells(r4, c4))
union(rng1, rng2).select
 
Thanks for your help

Jim Thomlinson said:
So it is a compound range you want then... try this

union(range(cells(r1, c1), cells(r2, c2)), range(cells(r3, c3), cells(r4,
c4))).Select

It defines two ranges based on RC co-ordinates and unions those 2 ranges
together...
To see it a little more clearly you could do this

dim rng1 as range
dim rng2 as range

set rng1 = range(cells(r1, c1), cells(r2, c2))
set rng2 = range(cells(r3, c3), cells(r4, c4))
union(rng1, rng2).select
 
Range("D8:F8","I8:K8").Select

Not sure if this is what you want, but one set of quotes gives you two
ranges.

Range("D8:F8 ,I8:K8").Select
 
Back
Top