在VBA(Excel 2010)中如何将默认情况恢复为变量? [英] How does one restore default case to a variable in VBA (Excel 2010)?

查看:119
本文介绍了在VBA(Excel 2010)中如何将默认情况恢复为变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在某些时候,我意外地命名一个变量 range (所有小写字母),然后Visual Basic for Applications编辑器拒绝使用 Range (Pascal-cased);它将自动更正为小写。我如何重新设置大脑来忘记我过去的犯罪行为?



注意:我已经尝试了全局替换,但是当我编辑任何一个线条 - 它再次重新纠正。



显然这是一个非常非常的轻微化妆品问题,但每次看着R都跛行我输入范围是有刺激性的。

解决方案

您需要更改名称的声明行中的变量( Dim 语句)在某处(任何地方,实际上)。



这是VBA IDE最令人讨厌的功能之一(如果版本控制不够用VBA,不断变化的驱动我蝙蝠)。 变量在VBA IDE中全局变化,而不管变量的实际范围。 VBA IDE似乎采用了最近声明的胜利。


$ b $通常所有你需要做的只是更新一个声明行的某个地方的情况,但VBA可能是顽固的。我还没有完全破解代码。



注意:由于@Scorchio在下面的评论中指出,变量在当前项目中全局变化;可能在VBA IDE中打开的其他项目(例如在Excel中工作的其他工作簿)不受影响。


At some point I accidentally named a variable range (all lower-case) and since then the Visual Basic for Applications editor refuses to use Range (Pascal-cased); it will auto-correct it to lower-case. How can I reset its "brain" to forget about my past transgression?

NOTE: I've tried doing a global replace-all, but the moment I edit any single line -- it re-corrects once again.

Obviously this is a very very minor, cosmetic issue but watching the R go limp every time I type Range is irritating.

解决方案

You need to change the name of the variable in a declaration line (Dim statement for example) somewhere (anywhere, actually).

This is one of the most annoying "features" of the VBA IDE (as if version control weren't already hard enough with VBA, the constant case-changing drives me batty). Variables have their case changed globally in the VBA IDE, regardless of the variable's actual scope. The VBA IDE seems to take the approach of most recent declaration wins.

Usually all you need to do is just update the case in a declaration line somewhere, but VBA can be obstinate. I've yet to crack the code completely.

Note: As @Scorchio points out in the comments below, the variable case is changed globally within the current project; other projects that may be open in the VBA IDE (such as other workbooks when working in Excel) are NOT affected.

这篇关于在VBA(Excel 2010)中如何将默认情况恢复为变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆