How to calculate A1-style ranges

G

Guest

Guest
How do you create a reference to a range where you need to calculate the bottom right-hand corner of the range? For example, I know the range starts at J8, I know the right-hand edge of the range is column L, and I have a variable that contains the number of rows. I need a reference that looks like:
Range ("J8:L230")
but using the variable instead of 230. How do I do this?
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hi,

There are various methods you can use:- How about using the Resize property e.g.

Sub ExtendRange()
Dim rngeLeftTopCell As Range, rngeNewRange As Range
Dim lngNumberOfColumns As Long, lngNumberOfRows As Long

'This is the top left cell of the current selection
Set rngeLeftTopCell = Range("J8")

'Number of rows and columns you want the range increased by
lngNumberOfRows = 223
lngnumberofcols = 3

Set rngeNewRange = rngeLeftTopCell.Resize(lngNumberOfRows, lngnumberofcols)

MsgBox rngeNewRange.Address


End Sub

HTH,
D
This message was edited by dk on 2002-02-17 04:12
 
Upvote 0

Forum statistics

Threads
1,215,110
Messages
6,123,140
Members
449,098
Latest member
Doanvanhieu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top