Named Range shorthand question

beckyinDC

Board Regular
Joined
Mar 24, 2011
Messages
56
just wondering if someone could explain (and please correct me if I am misunderstanding) how Excel is behaving...

I have named ranges: [Issues_Alert] and [Total_Issues_Opened]

...why can I set up a string : "There are " & [Total_Issues_Opened] & " issues open"

...but I cannot use the same shorthand to set the other named range to that value- the following gets me an Object is needed error:

[Issues_Alert] = "There are " & [Total_Issues_Opened] & " issues open"

macro recording seems to show that I need to go through the Application.Names object to get to the Issues_Alert name to set the value...more wordy and I feel like I dont understand when I can use the shorthand and when I cant.

I can move forward with this coding using application.names-
ActiveWorkbook.names("Issues_Alert").RefersTo = "Text string"

but any tips would be appreciated -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.
It appears that Issues_Alert is not a named range but a defined name that has a literal value. The Evaluate function (for which [] is a shorthand notation) returns a literal string and you then try to assign another string to it which makes no sense.
 
Upvote 0
Just an aside:

This illustrates why it is a bad idea to use the lazy square bracket shorthand notation. Use the complete VBA hierarchical referencing, including the defaults (equally important), and you will not encounter this type of error, and the code will be more completely self-documented.
 
Upvote 0

Forum statistics

Threads
1,224,531
Messages
6,179,384
Members
452,908
Latest member
MTDelphis

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