XL2000: "Type Mismatch" Comparing String Variable to Boolean (213589)
The information in this article applies to:
This article was previously published under Q213589 SYMPTOMS
In Microsoft Excel 2000, when you run a macro that runs successfully in Microsoft Excel 95 or earlier, you may receive the following error message:
Run-time error '13':
Type Mismatch
CAUSE
This problem may occur when the macro compares a String variable to a Boolean variable.
In Microsoft Excel, a variable that you define as a String type cannot be compared to the Boolean values True or False without generating a run-time error.
This behavior is by design of Microsoft Excel.
WORKAROUND
To work around this problem, define the variable that you want to compare
to a Boolean variable as Variant instead of String; you can compare a Variant variable to a Boolean variable without generating an error. For example, if the macro contains a line similar to the following
Dim S As String
replace it with the following line:
Dim S As Variant
Modification Type: | Minor | Last Reviewed: | 10/10/2006 |
---|
Keywords: | kbdtacode kberrmsg kbprb kbProgramming KB213589 |
---|
|