Siegfried BIC
Siegfried BIC

Reputation: 161

VBA automatically changing .Range to .range

I have been writing an Excel macro to help me process data at work, and now that I have finished writing the code I keep getting errors because Microsoft Visual Basic keeps changing .Range to .range. Whenever it does this I get a compile error because the method doesn't exist.

Is there anyway to fix this? Is there a way to get around using .Range if there isn't? As long as my code keeps getting changed from .Range to .range it will keep spitting out errors here.

SOLVED: the error wasn't rooted in the method but the data member that preceded it.

Upvotes: 15

Views: 7892

Answers (4)

Shari P
Shari P

Reputation: 21

I have several models and procedures, and at some point all of my Ranges got converted to lowercase range. My easy fix was to go to ThisWorkbook in my project, and Dim Range as Range there, and then it will automatically change "range" to "Range" everywhere it appears in your code

Upvotes: 2

Chrismas007
Chrismas007

Reputation: 6105

EDIT: The O.P. stated:

SOLVED: the error wasn't rooted in the method but the data member that preceded it.

However, the related issues of a lowercase method can come from creating a variable or routine which you named range and the system will auto change case based on that definition. You should never create a variable or routine with the same name as a defined process like Range(). As mentioned by @RubberDuck:

This is a side effect of VB being case insensitive and the IDE trying to be "helpful".

Upvotes: 7

kaybee99
kaybee99

Reputation: 4744

Try declaring Range as a Range somewhere in your code (note the case):

Dim Range As Range

then delete the statement.

This should convert all your range to Range

Upvotes: 38

Liniel
Liniel

Reputation: 729

When you have use many times words like 'range', autocorrect will change 'Range' value to 'range'. Try manually change this method to 'Range' and sure that you don't have any variables like 'range'.

Upvotes: 0

Related Questions