Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

reserved names r1_, c1_? 1

Status
Not open for further replies.

electricpete

Electrical
May 4, 2001
16,774
When naming ranges, we of course can't use a single letter and number (For example a1), because that is indistuinguishable from a cell address.

So I always add an underscore after cell names like that. Works fine most of the time: a1_, b1_, d1_, e1_, etc are fine. a2_, b2_, d2_, e2_, etc are also fine.

I noticed that if I try to use r1_ or c1_, I get an error message "c1_ is not a valid name" and "r1_ is not a valid name". Likewise, excel doesn't like r2_ or c2_.

Does anyone know why these particular names are prohibited? r and c reminds me of row and column, but I have not idea why r1_ and c1_ would be reserved.

=====================================
Eng-tips forums: The best place on the web for engineering discussions.
 
Replies continue below

Recommended for you

I haven't looked into this at all, but I suspect you have 99% answered your own question.
 
I have another name that is not allowed. This is a single letter, "R". Why?
 
R stands for Row, C stands for Column. There are two ways to address a cell; the typical A23 and also RC format.
A1 versus RC addressing

Excel addresses can be expressed in two styles, A1 style and RC style. A1 style uses one or more letters for the column, starting at "A" (column 1) and ending at "IV" (column 256); the letters are followed by an integer for the row (1 to 65536). RC style uses "RrCc" where r is the row number and c is the column number, e.g. "R1024C251". Thus "B3" and "R3C2" can refer to the same cell.

The user can choose either style to be displayed in a workbook (the default is A1). Each style supports both absolute and relative addressing (see below).

If you are generating a formula using code, or parsing an existing formula, it is generally much simpler to use RC style. However, the conversion methods in the XLL+ classes, such as CXlRef::ToString and CXlRef::FromString, support both A1 and RC style, so you can use either style as you prefer.

Note that for Excel versions in languages other than English, the letters "R" and "C" in an RC-style address will be in the local language. For example, the English address "R1C1" will be displayed as "Z1S1" in German. See also International issues above.

To be honest, you should be giving your named ranges more intuitive names. You can prefix rng (short for Range) and name them anything you like. E.g. in macros, rngRow is perfectly acceptable, as is strRow, etc. but Row will get you into trouble as it's an existing object.
 
Thanks. That is good info. I realize I can't use a name that is ambiguous and can be mistaken, but I thought the underscore would take care of that.

R1_ and C2_ L3_ etc are very intuitive names to me when trying to simulate a circuit which is labelled in the same manner. I guess I'll go with Res1, Cap2, L3_.

=====================================
Eng-tips forums: The best place on the web for engineering discussions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor