Macro that recognises cell value as a range name

arod

Board Regular
Joined
Feb 8, 2008
Messages
103
I am trying to get a macro that will recognize the text in a cell as a reference to a range name and then perform actions to this range.
For example:
• In A1 I have the text ‘Range1’
• ‘Range1’ is a named range referring to cells A2:A5
• I am currently using the code:
Range(“Range1”).Select
Selection.Copy
• This only selects A1 rather than actually selecting A2:A5

Does anyone know how I can get this to work?

Thanks
 

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.
try:

Code:
Var = Range("A1").Value
Range(Var).Select
Selection.Copy

where VAR is any variable name or letter that you want to use
 
Upvote 0
first thing: spelling mistake "coutner" instead of Counter?? and secondly, what are you trying to count and can you give an example of the data and the situation in which this code would be used?
 
Upvote 0
If you enter a name in the Name Box (the one to the left of the formula box) and press enter, you will select that named range. No macro is needed.
 
Upvote 0

Forum statistics

Threads
1,224,506
Messages
6,179,159
Members
452,892
Latest member
yadavagiri

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