How to name a range that's flexible?

hoopeht

New Member
Joined
Feb 16, 2016
Messages
3
If you need to name a range in a spreadsheet, you would normally highlight the cells and type a name in the name box on the top left corner. But what do I do if the range needs to be flexible?

In cell A1, the user specifies an integer, say 10. I want B1:B10 to be named "user specified range". If the user specifies a different integer in A1, say 5, then B1:B5 would be named "user specified range".

How do I write a sub to make this happen?
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
You don't need a sub, you can do that with Names. Go into the Name Manager and define a name.

Name: UserSpecifiedRange
RefersTo: =Sheet1!$B$1:INDEX(Sheet1!$B:$B, Sheet1!$A$1, 1)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,793
Members
451,589
Latest member
Harold14

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