View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jon Peltier Jon Peltier is offline
external usenet poster
 
Posts: 6,582
Default Discontinuous Range via VBA using R1C1?

Range() takes one or two arguments. If one, it has to be a recognizable
range address, if two it has to be references to two diametrically opposed
corners of the range. Range("R3C8:R14C8") didn't work for me, but you can
easily decompose RrCc into Cells(r,c). Then use Union to connect
discontiguous areas.

Try something like this:

Union(Range(cells(3,8),cells(14,8)), Range(cells(3,12),cells(14,13))).Select

which worked for me from the Immediate window.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"(PeteCresswell)" wrote in message
...

MsgBox Range("H3:H14,L3:M14").Address(ReferenceStyle:=xlR 1C1) yields
-------------------------
R3C8:R14C8,R3C12:R14C13
-------------------------

but the VBA coding
---------------------------------------
Range(R3C8:R14C8, R3C12:R14C13).Select
---------------------------------------

doesn't even get past the parser - the line turns red and that's the end
of it.


Intuitively,
------------------------------------------------------------------------------
With ActiveSheet
Range(.Cells(3, 8), .Cells(14, 8), .Cells(3, 12), .Cells(14,
13)).Select
End With
------------------------------------------------------------------------------
seems tb closer, but it dies at compile time with "Wrong number of
arguments or
invalid property assignment".

Can anybody give me a nudge in the right direction?
--
PeteCresswell