general question on code ("A1") versus [A1]

Kade

Active Member
Joined
Jul 20, 2002
Messages
258
Hi all

what is the diference in code between round bracket parenthesis and square brackets.

sometimes they seem interchangeable and other times not

tia kd
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Hi Kade,

They are only interchangeable when the references are literals, i.e., when the string that defines the range or range name is "hard-coded" as opposed to computed. So

[B4] is equivalent to Range("B4"),

but you cannot us the bracketed syntax to accomplish

Range("B" & i)

where i is an integer value representing a row index.

Also, the Range("...") syntax is more efficient (in execution speed) than the bracketed method, although this is only very rarely an issue.

Damon
 
Upvote 0
Howdy Kade, love this question, a good one. The brackets are the hard-coded variety of evaluate.

For example:<pre>
[a1].Activate</pre>

Is the equivalent of:<pre>
Evaluate("a1").Activate</pre>

There is much more to them than referencing ranges. For a great, in-depth explanation, I recommend the following post by Monsieur Laurent Longre:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=366730CB.1FB1@wanadoo.fr&rnum=5

IMO, A must read.

_________________
Cheers,<font size=+2><font color="red"> Nate<font color="blue"> Oliver</font></font></font>
This message was edited by NateO on 2002-12-09 18:36
 
Upvote 0

Forum statistics

Threads
1,221,711
Messages
6,161,450
Members
451,707
Latest member
PedroMoss2268

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