I've never seen a situation in which that code wouldn't compile.
Of course, it blows up at run-time, but it should compile.
No, there's no way to catch such errors when you write or compile
the code.
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
"RB Smissaert" wrote in message
...
Was caught out by something tricky that I thought might be
worth it to pass on.
Had coded, simplified, this code:
Sub test()
Dim strTest As String
If strTest = 4 Then
MsgBox strTest
End If
End Sub
Strangely, this sometimes compiles and sometimes doesn't.
Unfortunately, it did with me, but it can't run as there
obviously will be an error:
Type mismatch (Error 13)
Strangely also it can sometimes run on Excel 2003, but as far
as I can see never on 2000.
Just completely unpredictable.
Would there be a way to catch out this coding error reliably at
compile time?
RBS