ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   construct range? (https://www.excelbanter.com/excel-programming/322470-construct-range.html)

Jeff Higgins

construct range?
 
I have a single cell range named StartRange.
I would like to construct a multi-cell range named TestRange.
The first cell of TestRange would be StartRange and the last cell of
TestRange would be StartRange.Row + RowInteger, StartRange.Column +
ColumnInteger

Dim StartRange As Range
Dim TestRange As Range
Dim RowInteger As Integer
Dim ColumnInteger As Integer

Set StartRange ActiveCell
RowInteger = 4
ColumnInteger = 5

'Doesn't work
Set TestRange = Range(StartRange,
Range(StartRange).Item(RowInteger,ColumnInteger))

Please help
Thanks Jeff Higgins

Tim Williams

construct range?
 
Try something like

set TestRange=Union(StartRange, AnotherRange)

Tim.


"Jeff Higgins" wrote in
message ...
I have a single cell range named StartRange.
I would like to construct a multi-cell range named TestRange.
The first cell of TestRange would be StartRange and the last cell of
TestRange would be StartRange.Row + RowInteger, StartRange.Column +
ColumnInteger

Dim StartRange As Range
Dim TestRange As Range
Dim RowInteger As Integer
Dim ColumnInteger As Integer

Set StartRange ActiveCell
RowInteger = 4
ColumnInteger = 5

'Doesn't work
Set TestRange = Range(StartRange,
Range(StartRange).Item(RowInteger,ColumnInteger))

Please help
Thanks Jeff Higgins




Jeff Higgins

construct range?
 
Dim StartRange As Range
Dim RowInteger As Integer
Dim ColumnInteger As Integer
Dim TestRange As Range

Set StartRange ActiveCell
RowInteger = 4
ColumnInteger = 5

'Does work but seems convoluted
Set TestRange = Range(StartRange.Address, _
Application.Cells(StartRange.Row + RowInteger, _
StartRange.Column + ColumnInteger).Address))

"Jeff Higgins" wrote:

I have a single cell range named StartRange.
I would like to construct a multi-cell range named TestRange.
The first cell of TestRange would be StartRange and the last cell of
TestRange would be StartRange.Row + RowInteger, StartRange.Column +
ColumnInteger

Dim StartRange As Range
Dim TestRange As Range
Dim RowInteger As Integer
Dim ColumnInteger As Integer

Set StartRange ActiveCell
RowInteger = 4
ColumnInteger = 5

'Doesn't work
Set TestRange = Range(StartRange,
Range(StartRange).Item(RowInteger,ColumnInteger))

Please help
Thanks Jeff Higgins


Tim Williams

construct range?
 
Maybe

Set TestRange = Range(ActiveCell,
ActiveCell.offset(RowInteger,ColumnInteger))

I'm not exactly sure what range you're trying to obtain, but this
would give you a rectangular range with the activecell being topleft,
and the bottom right cell being RowInteger cells down and
Columninteger cells to the right.

Tim



"Jeff Higgins" wrote in
message ...
Dim StartRange As Range
Dim RowInteger As Integer
Dim ColumnInteger As Integer
Dim TestRange As Range

Set StartRange ActiveCell
RowInteger = 4
ColumnInteger = 5

'Does work but seems convoluted
Set TestRange = Range(StartRange.Address, _
Application.Cells(StartRange.Row + RowInteger, _
StartRange.Column + ColumnInteger).Address))

"Jeff Higgins" wrote:

I have a single cell range named StartRange.
I would like to construct a multi-cell range named TestRange.
The first cell of TestRange would be StartRange and the last cell
of
TestRange would be StartRange.Row + RowInteger, StartRange.Column +
ColumnInteger

Dim StartRange As Range
Dim TestRange As Range
Dim RowInteger As Integer
Dim ColumnInteger As Integer

Set StartRange ActiveCell
RowInteger = 4
ColumnInteger = 5

'Doesn't work
Set TestRange = Range(StartRange,
Range(StartRange).Item(RowInteger,ColumnInteger))

Please help
Thanks Jeff Higgins




Jeff Higgins

construct range?
 
Tim,
yes, the range I have been seeking is as you say.
offset method, of course!!!
Thanks for your help, much appreciated.
Jeff

"Tim Williams" wrote:

Maybe

Set TestRange = Range(ActiveCell,
ActiveCell.offset(RowInteger,ColumnInteger))

I'm not exactly sure what range you're trying to obtain, but this
would give you a rectangular range with the activecell being topleft,
and the bottom right cell being RowInteger cells down and
Columninteger cells to the right.

Tim




All times are GMT +1. The time now is 05:23 PM.

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