Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Using R1C1 in VB to select a range

I've seen a lot of posting about using the R1C1 format to select cells when
using VB to program a function into a cell, but not a lot about how to use
the R1C1 format to select a range for use in a VB Macro.

If I am in cell CA91 and I want to select the range starting at CA92 through
CE176, how to I program that into VB? I tried "range(rc1:r4c84).select" and
it doesn't like the colon. I then tried "range(rc[1]:r[4]c[84]).select" and
it bombed on the first open bracket ([).

Any ideas? I can't use the direct addresses since I won't always know where
I'm going to start this macro from.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Using R1C1 in VB to select a range

if you want Range("R1C1:R4C84") to be selected, you can use the following
code:
1. Range("A1:CE4").select
or
2. Range(Cells(1, 1), Cells(4, 84)).select

Best Regards
John Black

"Robert_L_Ross" wrote in message
...
I've seen a lot of posting about using the R1C1 format to select cells

when
using VB to program a function into a cell, but not a lot about how to use
the R1C1 format to select a range for use in a VB Macro.

If I am in cell CA91 and I want to select the range starting at CA92

through
CE176, how to I program that into VB? I tried "range(rc1:r4c84).select"

and
it doesn't like the colon. I then tried "range(rc[1]:r[4]c[84]).select"

and
it bombed on the first open bracket ([).

Any ideas? I can't use the direct addresses since I won't always know

where
I'm going to start this macro from.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Using R1C1 in VB to select a range

Robert,
You might find this easier:

Sub GetRange()
Dim rng As Range
Set rng = Range("CA92").Resize(85, 5)
rng.Select
End Sub

Or .... where Activecell=CA91 to use your example

Sub GetRange()
Dim rng As Range
Set rng = ActiveCell.Offset(1, 0).Resize(85, 5)
rng.Select
End Sub

Avoid using select as much as possible as it slows performance. I used it to
illustrate that the range was correct.

HTH

"Robert_L_Ross" wrote:

I've seen a lot of posting about using the R1C1 format to select cells when
using VB to program a function into a cell, but not a lot about how to use
the R1C1 format to select a range for use in a VB Macro.

If I am in cell CA91 and I want to select the range starting at CA92 through
CE176, how to I program that into VB? I tried "range(rc1:r4c84).select" and
it doesn't like the colon. I then tried "range(rc[1]:r[4]c[84]).select" and
it bombed on the first open bracket ([).

Any ideas? I can't use the direct addresses since I won't always know where
I'm going to start this macro from.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Range selection with R1C1 Adam1 Chicago Excel Discussion (Misc queries) 6 November 8th 07 04:02 PM
Dynamic Range in Macro with R1C1 Jonnyboy117 Excel Programming 3 July 9th 04 04:40 PM
Select Range using R1C1 verizon Excel Programming 4 June 16th 04 01:11 PM
R1C1 to Range Jahson Excel Programming 3 February 17th 04 12:29 PM
Using Range with R1C1 notation in a macro J Excel Programming 1 January 23rd 04 04:46 AM


All times are GMT +1. The time now is 02:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"