Thread: Type mismatch !
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Leith Ross[_255_] Leith Ross[_255_] is offline
external usenet poster
 
Posts: 1
Default Type mismatch !


Hello Roshintosh & Paul,

Worksheet cells are all variants. When an error is found, Excel set
the cell to an Error type variant. This can be verified 2 ways. Firs
by using IsError() and second by using VarType(). IsError will retur
True if the cell is an Error variant type and VarType returns 10 if th
cell is an Error variant type.

To answer your question about getting a cell value, if there is a
error Excel will only return the Error, not the value. So, your bes
bet is test for an error and handle it.

The help files tell you how to raise an error in cell, but not how t
convert an Error type back to something useful like an Error Number
Here's how to do that...

Sub ErrorTest()

Dim Ret
Dim ErrNum

Ret = Range("A1").Value
If IsError(Ret) Then
E = CInt(Ret)
End If


End Sub

Hope this helps you some.

Sincerely,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=48380