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

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
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,213,506
Messages
6,114,027
Members
448,543
Latest member
MartinLarkin

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