Referencing Ranges Regularly

TwistShout

New Member
Joined
Aug 17, 2011
Messages
15
This is a quality of life issue.....
Is there a better way to refer to a dynamic range than
Range(Range("A2"), Range("A2").end(xldown))
or
Range(Range("A2"), Range("B2").end(xldown)).

My code starts to packed and jumbled and ,if possible, this could make it easier to review/create.

potential thanks.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Not tested but you could do something like:

Code:
dim rng as Range
set rng = Range(Range("A2"), Range("A2").end(xldown)) 

with rng
...
...
...
end with
 
Upvote 0
Hi TwistShout,
Try ~
Go to formulas menu, click name manager, click new, enter a name say Arg, in the refers to box copy and paste this formula into the refers to box ~

=OFFSET($A$1,1,0,COUNTA(OFFSET($A$1,1,0,9999)),1)

Now you can refer to the dynamic range as ~
dim rng as Range
set rng = Range("Arg")

with rng
...
...
...
end with

Cheers
 
Last edited:
Upvote 0
thanks, both answers are basically what I was looking for. I will have to take a few minutes to break down asking's formula tho.
 
Upvote 0

Forum statistics

Threads
1,224,578
Messages
6,179,650
Members
452,934
Latest member
mm1t1

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