Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Max length of variable name?

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Max length of variable name?

On Mon, 12 Apr 2010 09:49:01 -0700, David
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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Max length of variable name?

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" wrote in message
...
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Max length of variable name?

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" wrote in message
...
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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Max length of variable name?

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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Max length of variable name?

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" wrote in message
...
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


.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Max length of variable name?

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" wrote in message
...
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

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
.



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Max length of variable name?

On Mon, 12 Apr 2010 11:39:01 -0700, David
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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable Axis Length Krys Charts and Charting in Excel 2 July 1st 08 08:19 PM
SUM for columns of variable length excelhack Excel Programming 2 May 2nd 07 04:35 PM
Max/Min for variable length columns Tim Rush[_2_] Excel Programming 6 January 5th 06 04:36 PM
Sum a Column of Variable length Chris G Excel Discussion (Misc queries) 4 November 7th 05 12:25 PM
Sum a column of variable length? Brian Excel Discussion (Misc queries) 5 February 3rd 05 02:26 PM


All times are GMT +1. The time now is 09:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"