Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Variable Axis Length | Charts and Charting in Excel | |||
SUM for columns of variable length | Excel Programming | |||
Max/Min for variable length columns | Excel Programming | |||
Sum a Column of Variable length | Excel Discussion (Misc queries) | |||
Sum a column of variable length? | Excel Discussion (Misc queries) |