VBA changes automatically. Change to .range

I am 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. Change to .range. Whenever this happens, I get a compilation error because the method does not exist.

Is there any way to fix this? Is there any way around the use. Change if not? As long as my code keeps changing from .Range to .range, it will continue to spit out errors here.

SOLVED: The error was not injected into the method, but the data item that preceded it.

+5
source share
3 answers

Try declaring the 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

+7
source

EDIT: OP stated:

SOLVED: The error was not injected into the method, but the data item that preceded it.

However, problems associated with the child method may result from creating a variable or subroutine that you called range , and the system will automatically change case based on this definition. You should never create a variable or routine with the same name as a specific process, such as Range() . As @RubberDuck mentioned:

This is a case-insensitive VB side effect, and the IDE is trying to be "useful."

+4
source

When you use words such as β€œrange” many times, autocorrection will change the value of β€œRange” to β€œrange”. Try manually changing this method to "Range" and make sure that you do not have any variables of the type "range".

0
source

Source: https://habr.com/ru/post/1208817/


All Articles