ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selecting a range offset from a cell (https://www.excelbanter.com/excel-programming/326559-selecting-range-offset-cell.html)

Beeegr8

Selecting a range offset from a cell
 
I want help with the code associated with selecting an area one row down to 4
columns across (the row below the cell and 4 columns wide) from a specific
cell. I don't want to use the EntireRow feature as I only want to see an
area 1 row by 4 columns wide. There is additional info to the right of this
area that I do not want to select. For example, if my cursor is in A1, I want
to be able to select A2:D2. The cursor will not always be in the same cell so
I assume I need to use some sort of a reference with an offset.

TroyW[_2_]

Selecting a range offset from a cell
 
Take a look at Offset and Resize. Used in combination, you can select a
desired contiguous block of cells.

Troy

Sub Test1()
Dim rng As Range

Set rng = ActiveCell.Offset(1, 0).Resize(1, 4)
rng.Select
End Sub

"Beeegr8" wrote in message
...
I want help with the code associated with selecting an area one row down to
4
columns across (the row below the cell and 4 columns wide) from a
specific
cell. I don't want to use the EntireRow feature as I only want to see an
area 1 row by 4 columns wide. There is additional info to the right of
this
area that I do not want to select. For example, if my cursor is in A1, I
want
to be able to select A2:D2. The cursor will not always be in the same cell
so
I assume I need to use some sort of a reference with an offset.




Alan Beban[_2_]

Selecting a range offset from a cell
 
Beeegr8 wrote:
I want help with the code associated with selecting an area one row down to 4
columns across (the row below the cell and 4 columns wide) from a specific
cell. I don't want to use the EntireRow feature as I only want to see an
area 1 row by 4 columns wide. There is additional info to the right of this
area that I do not want to select. For example, if my cursor is in A1, I want
to be able to select A2:D2. The cursor will not always be in the same cell so
I assume I need to use some sort of a reference with an offset.


No need for the Offset function:

ActiveCell(2).Resize(, 4).Select

Alan Beban


All times are GMT +1. The time now is 11:59 AM.

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