Timmy
Timmy

Reputation: 12848

Mapping a "Name" to an Range

I setup a "Name" to a column range, and I want to reference it later on:

Dim r As Range
r = Application.Names("Changes").Something

I've tried a bunch of "Something" but cannot get this right. Thanks.

Upvotes: 1

Views: 502

Answers (4)

Mark
Mark

Reputation: 108567

Try:

Set r = Application.Names("Changes").RefersToRange

Upvotes: 2

Stewbob
Stewbob

Reputation: 16899

dim r as Range
Set r = Range("Changes")

The 'Set' keyword is very important.

This will work for any size range, including a single cell.

Then you can access the properties and methods of your range variable 'r'.

Upvotes: 3

thomas
thomas

Reputation: 2642

does this work?

Dim R As Range
Set R = ThisWorkbook.Names("Changes").RefersToRange

I think it will only work if the range is 2 cells or more. If it is one you have to do something else...don't really remember though.

Another way is as follows.

Sheets("Name").Range("Changes")

Upvotes: 1

Jacob G
Jacob G

Reputation: 3665

Do either RefersTo or RefersToRange work?

Upvotes: 1

Related Questions