From: David on
Hi,

I am at a loss to explain why the above gave me a problem, but I guess since
I changed it, it no longer matters.

Thanks for your help.
--
David


"Rick Rothstein" wrote:

> 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: JLGWhiz on
The variable is limited. The value of the variable is subject to the
conventions of the application. i.e. Excel will automatically convert some
numbers to scientific format which would be less characters than the actua
value contained in VBA. Also Excel will round certain numbers, which again
would be different than the actual value defined by VBA. So, if you are
attempting to draw some static conclusion as to the Variable vs Variable
value, you will find it difficult to do without an understanding of how
Excel interacts with VBA.




"David" <David(a)discussions.microsoft.com> wrote in message
news:27C0AC6D-321D-4123-9442-D52538A5C1EF(a)microsoft.com...
> 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
>> .
>>


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

>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
>--

1. You still haven't provided any information I can see as to why you think a
variable name is too long. Are you getting an error message? Unexpected
result? System crash? etc. If so, what is the nature of the error message
(what does it say) or other dysfunction.

2. How are your variables DIM'd?
3. Where do the values for these variables come from -- How did the numbers
get into them?

We really can't read minds, so the more information you can provide, the easier
it is to help you.
--ron
First  |  Prev  | 
Pages: 1 2
Prev: Message box shadow
Next: help needed