ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Range Selection (https://www.excelbanter.com/excel-programming/352907-range-selection.html)

Steve C

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!

Don Guillett

Range Selection
 
why are you selecting in the first place. Tell us what you are trying to do
and we can suggest a better way.

--
Don Guillett
SalesAid Software

"Steve C" wrote in message
...
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!




sebastienm

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!


Steve C

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!



All times are GMT +1. The time now is 01:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com