Why 'Row' changes to 'row' in Exce

2019-01-28 22:01发布

For unknow reason my Excel VBA editor changes:
Cells(ActiveCell.Row, 1).Value = MyString
into
Cells(ActiveCell.row, 1).Value = MyString

Word "Row" should start with capital "R" but after I type it, it changes to small "r". I have checked the code and I am sure I do not use "raw" as a variable. The macro itself works fine as if it was written "Row". On other workbooks everything is ok (R is capitalized).

Anybody has idea why it happens?

3条回答
走好不送
2楼-- · 2019-01-28 22:36

VBA isn't case sensitive, so I wouldn't lose too much sleep over it. The editor tries to convert all of the variable cases to however it was dimmed. Most likely the ActiveCell definition was screwed up somehow.

查看更多
爷、活的狠高调
3楼-- · 2019-01-28 22:55

I was also getting a bit tired of from looking where exactly I have declared a Row with a small letter, as far as it was not declared anywhere.

Thus, found a great solution - add the following in a module:

Public Sub TestMe
   Dim Row as Long
End Sub

And see the whole code changing. Then you may delete it. Or simply write Dim Row as Long on a new line, somewhere in your code. And then delete it.

查看更多
何必那么认真
4楼-- · 2019-01-28 22:55

I used variable row in VBA of that worksheet. Then I changed the name of the variable row to something else like MyRowName Although there was no such variable as row in VBA anymore, it still kept lower case for that word. As I mentioned above everything worked fine i.e. ActiveCell.row returned what it should for ActiveCell.Row.

For just aesthetic reasons, I have copied the whole VBA to another worksheet and the bug was crunched. Row returned to Upper case.

查看更多
登录 后发表回答