VBA for getting Range of Name(Dynamic Range)

ljtong

Board Regular
Joined
May 23, 2005
Messages
71
Hi all,

I'm having trouble in getting the range that a name(dynamic range) refers to. I want the range so I can then go Range.select

why does this not work?

Code:
MsgBox (Workbooks("Gap").Worksheets("SlowDown").Names("Data").RefersToRange)

If I use

Code:
MsgBox (Workbooks("Gap").Worksheets("SlowDown").Names("Data").RefersTo)

I get the formula (=offset......) only

"Data" is actually "SlowDown!Data"


Also, what is the difference between select and activate?
as in worksheets("aa").select doesn't seem to be different from .activate
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Of course!! RefersToRange returns a Range...

Code:
MsgBox (Workbooks("Gap").Worksheets("SlowDown").Names("Data").RefersToRange.address)
 
Upvote 0
Ah.. we posted at the same time jon

names("data").address doesn't work unfortunately

RefersToRange.Address works ok now

any thoughts on the select/activate difference..?
 
Upvote 0
Try this, you need to set a range object, but not the Sheet, only the Workbook needed!

Sub myRange()

'Set myWBS = Workbooks("Gap")
Set myWBS = ThisWorkbook

MsgBox myWBS.Names("Data")
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,029
Messages
6,122,757
Members
449,094
Latest member
dsharae57

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