Minimum Length of Variable Name

User avatar
Don Wells
5StarLounger
Posts: 689
Joined: 27 Jan 2010, 16:45
Location: Ottawa, Ontario, Canada

Minimum Length of Variable Name

Post by Don Wells »

Running Office 2003

I was surprised to discover that the following code does not throw an error until line 30'.

Code: Select all

Option Explicit

Public Sub kkk()

10    K = ThisWorkbook.Path
20    L = K
30    LA = ThisWorkbook.Path

End Sub
Is it common that a variable named with a single character, escape testing by the compile process? Or is my machine acting up?
Regards
Don

User avatar
HansV
Administrator
Posts: 78545
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Minimum Length of Variable Name

Post by HansV »

Are you sure that K and L haven't been declared elsewhere?
I get a compile error on line 10:
S0231.png
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

User avatar
Don Wells
5StarLounger
Posts: 689
Joined: 27 Jan 2010, 16:45
Location: Ottawa, Ontario, Canada

Re: Minimum Length of Variable Name

Post by Don Wells »

Thank you Hans
    I was certain that I had thoroughly checked for the variable being declared elsewhere, so tried a reboot. While waiting for the machine the penny dropped. Remember this?
I have a module which I use solely as a temporary cache (Temp_Cache) containing 26 variant variables, A through Z.
     :blush:
Regards
Don

User avatar
HansV
Administrator
Posts: 78545
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Minimum Length of Variable Name

Post by HansV »

:hiding:
Best wishes,
Hans