Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Range Selection

I have written code that results in a range of cells being selected in one
column. (Each time the code is run, it selects a different range of varying
sizes, depending on what it is searching for). Once the range is selected,
I would then like to offset that selection by 3 columns and select the same
size range in that other column, plus the same size range in the column
immediately to the right of that one.

For example, let's say my code ends up selecting the range A10:A20. I then
want my code to offset that selection to D10:E20. Does that make sense?
Thanks for your help!
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Range Selection

Hi,

Dim rg as range, rg2 as range
set rg=range("A10:A20")
'If rg is a one-column single-area range
set rg2 = Rg.Offset(0,3).Resize(Rg.cells.count, 2)

--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Steve C" wrote:

I have written code that results in a range of cells being selected in one
column. (Each time the code is run, it selects a different range of varying
sizes, depending on what it is searching for). Once the range is selected,
I would then like to offset that selection by 3 columns and select the same
size range in that other column, plus the same size range in the column
immediately to the right of that one.

For example, let's say my code ends up selecting the range A10:A20. I then
want my code to offset that selection to D10:E20. Does that make sense?
Thanks for your help!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Range Selection

Thanks, Sebastien. That does the trick!

"sebastienm" wrote:

Hi,

Dim rg as range, rg2 as range
set rg=range("A10:A20")
'If rg is a one-column single-area range
set rg2 = Rg.Offset(0,3).Resize(Rg.cells.count, 2)

--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Steve C" wrote:

I have written code that results in a range of cells being selected in one
column. (Each time the code is run, it selects a different range of varying
sizes, depending on what it is searching for). Once the range is selected,
I would then like to offset that selection by 3 columns and select the same
size range in that other column, plus the same size range in the column
immediately to the right of that one.

For example, let's say my code ends up selecting the range A10:A20. I then
want my code to offset that selection to D10:E20. Does that make sense?
Thanks for your help!

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
Narrow Range based on Selection in Another Range David Excel Discussion (Misc queries) 3 July 1st 07 05:12 PM
Identifying a selection of a selection of a range swimfast Excel Worksheet Functions 1 March 1st 07 02:51 AM
Range selection Sagaron[_5_] Excel Programming 2 July 16th 05 12:08 PM
Excel VBA - Range(Selection, Selection.End(xlDown)).Name issue. jonH Excel Programming 3 June 7th 04 09:13 PM
Creating range name for a range selection Mervyn Thomas Excel Programming 1 January 26th 04 05:18 PM


All times are GMT +1. The time now is 06:26 AM.

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

About Us

"It's about Microsoft Excel"