ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   range selection object code (https://www.excelbanter.com/excel-programming/425947-range-selection-object-code.html)

Biologist Mike

range selection object code
 
Looking for the proper object code for using relative address logic (like
offset) in the range selection object to select multiple fields and rows
(block of cells) where I don't know the exact cell reference but only an
offset value. I use xldirection all the time but that only goes to the end
of a continuous block of cells with values. I need code that will allow me
to grab, say 2 or 3 columns of data at a time.
--
thanks,

Biologist Mike

Rick Rothstein

range selection object code
 
I think you are looking for the Resize method. Consider this example. Let's
say you wanted to select a range 3 cells wide by 5 cells high where the
upper left cell of that range was to be offset from the active cell 2 rows
down and 4 columns over...

ActiveCell.Offset(2, 4).Resize(5, 3).Select

So, if C3 was your active cell, then the above statement would select G5:I9.

--
Rick (MVP - Excel)


"Biologist Mike" wrote in message
...
Looking for the proper object code for using relative address logic (like
offset) in the range selection object to select multiple fields and rows
(block of cells) where I don't know the exact cell reference but only an
offset value. I use xldirection all the time but that only goes to the
end
of a continuous block of cells with values. I need code that will allow
me
to grab, say 2 or 3 columns of data at a time.
--
thanks,

Biologist Mike




All times are GMT +1. The time now is 10:13 AM.

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