XL97: "Type Mismatch" Comparing String Variable to Boolean (157107)
The information in this article applies to:
- Microsoft Excel 97 for Windows
This article was previously published under Q157107 SYMPTOMS
In Microsoft Excel 97, when you run a macro that runs successfully in an
earlier version of Microsoft Excel, the following error message may appear:
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 97, 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; a Variant variable can
be compared 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 KB157107 |
---|
|