VBA editor replaces 'Range' with 'range'

P

peter

In several Modules or Class Modules if I add a new line
"Dim r As Range",
the 'R' changes to 'r' when I press Enter.

Auto Syntax Check is not enabled.

I can't think of any changes I've made to the IDE
that could cause this.

Thanks for your help,
Peter.




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
G

Greg Wilson

I was able to replicate your problem by creating a variable with the name
"range" and declaring it as type "Range" - i.e. "Dim range As Range". I also
experimented with making it public - i.e. "Public range As Range". I don't
know if making it public was necessary. I don't think so.

Having done this, I can't make the problem go away either. I tried:
1) Deleting all the modules and recreating
2) Rebooting
3) Declaring a variable as "Range" publicly, with the Dim statement in a
class module as well as at module level in a standard module and at procedure
level in a standard module.
4) Unselecting Auto Syntax Check and other options

None of the above worked - i.e. the capital "R" always changes to lower case
"r". I guess it's a bug.

I did find that it is workbook specific. Also note that variables so
declared still seem to be recognized as of "Range" data type because an error
is generated if you don't use the Set statement.

Couldn't find a solution but I believe I found the cause. Hope this was of
some help.

Regards,
Greg
 
G

Greg Wilson

I tried that in my experiments also but forgot to mention it. "Excel.Range"
becomes "Excel.range" and if you type "Excel.range" it is accepted unchanged.

Regards,
Greg
 
P

peter

UPDATE

What prob. caused it was that I defined the name of a Property
method to be 'range'.

I've removed that and changed every other 'range' and there's
no sign of any in the Locals page.

But I've still got the problem, even after restarting VBA.

I didn't specifically say, but it's changed ALL my Ranges!

I sure hope someone can help, as I'm dead in the water
like this.

ciao,
Peter




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
N

NickHK

Greg,
Check the references and their order for the workbook. Any marked as missing
?
After typing "Excel." (with the full stop), what do you see ?

NickHK
 
G

Greg Wilson

None are listed as missing. When I type either "Excel." or "Dim abc As
Excel." the AutoList Members list appears. "Range" is included in the list.
When I select this, after it is automatically inserted, it then changes to
"range".

Regards,
Greg
 
D

Dick Kusleika

Peter

All you need to do is create a variable with the capitalization you want.
Then delete it.

Dim Range

the delete it. Now

Dim x As Range

will be capitalized how you expect.

When you create a variable (or property, in your case) that is a keyword,
VBA remembers the capitalization even after you delete the
variable/property. This just tricks into doing it right.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top