Ron Rosenfeld explained on 4/19/2012 :
On Thu, 19 Apr 2012 19:29:52 +0200, "Charlotte E." wrote:
I'm trying to add the following names to a workbook:
ActiveWorkbook.Names.Add Name:="A03_01", RefersToR1C1:=...
ActiveWorkbook.Names.Add Name:="B03_01", RefersToR1C1:=...
ActiveWorkbook.Names.Add Name:="C03_01", RefersToR1C1:=...
ActiveWorkbook.Names.Add Name:="D03_01", RefersToR1C1:=...
ActiveWorkbook.Names.Add Name:="E03_01", RefersToR1C1:=...
BUT!
Number 3:
ActiveWorkbook.Names.Add Name:="C03_01", RefersToR1C1:=...
Fails, with a message, saying that the name is invalid?!?
Why is "C03_01" invalid, and the rest are OK?!?
Thanks in advance...
CE
You do not write which version of Excel you are using. However, Names must
follow the allowed syntax and you will find that names that are "C", "c",
"R","r" or one of those letters followed by a number (in the range of values
for your workbook) are not allowed since they can also refer to addresses.
For example, in Excel 2007, with 16384 columns, C16384_01 is invalid, but
C16384_01 is valid.
Both these example names are identical! *When/where* is one invalid but
the same other one not invalid.
To workaround your problem, using something similar to your Naming scheme, I
would recommend you insert an underscore after the first Letter.
e.g: C_03_01 should be a valid name.
<FWIW
I'd recommend using a more descriptive naming scheme. This is just as
cryptic as using cell addresses, except users can figure out cell
addresses. Labels or field names would be more self-documenting and
much easier for users to understand the formulas using the names.
--
Garry
Free usenet access at
http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.
vb.general.discussion