This is a 64 bit issue.
^ can confuse the compiler as to whether an operator versus operand value as LongLong is being used.
This problem occurs because the circumflex character (^) is ambiguous in this context. For 64-bit versions of VBA, the circumflex has two meanings:
- It can designate an exponent operation, such as x to the power of y ("x^y").
- For 64-bit Office 2010 VBA editions only, it can designate that an operand value should be treated as a LongLong, 64-bit integer value data type (for example, "234^").
Consider the following scenario:
You have the 64-bit edition of Microsoft Office 2010 installed on your
computer. In the Visual Basic IDE, you create a new project.
In your Visual Basic for Applications (VBA) code, you type a statement
that resembles the following:
LongLongVar2 = LongLongVar1^IntegerVar
When you type x^y in the 64-bit Office 2010 VBA editions, the VBA IDE
editor does not know how to interpret the "x^" part of the string. In
this context, "x^" can be treated as being the LongLong data type. If
"x^" is interpreted in this manner, the string will produce an error
because there is no operator that is specified for the "y" value to
apply to the "x" value. If you type the string by using a space
between the value name and the circumflex (for example, x ^y), you
indicate that you intend the symbol to be an operator and not a data
type designator. By doing this, you can avoid the error condition.
Therefore, the example expression ... should be rewritten as follows:
LongLongVar2 = LongLongVar1 ^ IntegerVar