From: David on
Hi,

Sorry if this appears twice, could not tell if first posted.

What is the maximun length of a varaible name?

x=1 not problem, but
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=2 this is too long, yes? How long can it be?

Thanks,
--
David
From: Ron Rosenfeld on
On Mon, 12 Apr 2010 09:49:01 -0700, David <David(a)discussions.microsoft.com>
wrote:

>Hi,
>
>Sorry if this appears twice, could not tell if first posted.
>
>What is the maximun length of a varaible name?
>
>x=1 not problem, but
>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=2 this is too long, yes? How long can it be?
>
>Thanks,

You did not write what type of variable you are using, or why you think
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=2 is "too long". That makes it difficult to
advise you.

Since this is the programming group, and most posting about variable names in
this group would be using VBA, then:

"Variable names must begin with an alphabetic character, must be unique within
the same scope, can't be longer than 255 characters, and can't contain an
embedded period or type-declaration character."

Since this works:

=======================
Sub foo()
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = 2
Debug.Print xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
End Sub
======================

you are going to have to be more detailed in describing your problem.

--ron
From: JLGWhiz on
If you are passing the variable to a procedure, you are limited to 255
readable characters. The rest will be truncated. Outside of that, I have
not found a restriction on the number of characters. I suppose the correct
answer is that if it exceeds the length of the receptacle it will be used
in, then all excess characters will be truncated and unreadable.


"David" <David(a)discussions.microsoft.com> wrote in message
news:0FDAA811-39C6-42BB-BD82-86B7E4A692FB(a)microsoft.com...
> Hi,
>
> Sorry if this appears twice, could not tell if first posted.
>
> What is the maximun length of a varaible name?
>
> x=1 not problem, but
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=2 this is too long, yes? How long can it
> be?
>
> Thanks,
> --
> David


From: Rick Rothstein on
According to the "Visual Basic Naming Rules" section in Excel's VBA Help
Files, the maximum length of a variable name (also procedures, constants,
and arguments) is 255 characters; but, quite frankly, for practicality
reasons, your names should not be getting anywhere near that long.

--
Rick (MVP - Excel)



"David" <David(a)discussions.microsoft.com> wrote in message
news:0FDAA811-39C6-42BB-BD82-86B7E4A692FB(a)microsoft.com...
> Hi,
>
> Sorry if this appears twice, could not tell if first posted.
>
> What is the maximun length of a varaible name?
>
> x=1 not problem, but
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=2 this is too long, yes? How long can it
> be?
>
> Thanks,
> --
> David

From: David on
Hi,

The variables contain numbers.

The problem I had:
Tolerance = GrossTotal * 0.01 (This came out to about 1000)
TargetMMktPercent = ActiveCell.Offset(56, 0).Value
TargetMMkt = TargetMMktPercent * GrossTotal
TargetMMktHi = TargetMMkt + Tolerance
TargetMMktLo = TargetMMkt - Tolerance
(The last 2 statements had the same values and I had to change then to:
TargetMHi = TargetMMkt + Tolerance
TargetMLo = TargetMMkt - Tolerance
to get different values)

Thus the question about the length of a variable name, which if allowed 256
characters does not seem to make sense.

This did work:
Sub foo()
x = 1
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = 2
Debug.Print x & " " & xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
End Sub

Thanks
--
David


"Ron Rosenfeld" wrote:

> On Mon, 12 Apr 2010 09:49:01 -0700, David <David(a)discussions.microsoft.com>
> wrote:
>
> >Hi,
> >
> >Sorry if this appears twice, could not tell if first posted.
> >
> >What is the maximun length of a varaible name?
> >
> >x=1 not problem, but
> >xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=2 this is too long, yes? How long can it be?
> >
> >Thanks,
>
> You did not write what type of variable you are using, or why you think
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=2 is "too long". That makes it difficult to
> advise you.
>
> Since this is the programming group, and most posting about variable names in
> this group would be using VBA, then:
>
> "Variable names must begin with an alphabetic character, must be unique within
> the same scope, can't be longer than 255 characters, and can't contain an
> embedded period or type-declaration character."
>
> Since this works:
>
> =======================
> Sub foo()
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = 2
> Debug.Print xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> End Sub
> ======================
>
> you are going to have to be more detailed in describing your problem.
>
> --ron
> .
>
 |  Next  |  Last
Pages: 1 2
Prev: Message box shadow
Next: help needed