Thread: Type mismatch !
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Type mismatch !

Hi Roshintosh,

Declaring the variable as variant makes no difference unfortunately.


If the variable is declared as a string, the macro will break with a
run-time 13 type mismatch code.

I tried:

Sub ABC()
Dim var1 As Variant
var1 = Cells(1, 1).Value
Debug.Print "var1", var1
Debug.Print "#N/A error number", CVErr(xlErrNA)
End
End Sub

This produced the following in the imediate window:

var1 Error 2042
#N/A error number Error 2042

Thus, the variant variable correctly holds the cell's error value.

---
Regards,
Norman



"Roshintosh" wrote in message
oups.com...
Cheers Norman,

Declaring the variable as variant makes no difference unfortunately.

If the value in the cell is #N/A, then the statement

dim var1 as variant
var1 = Cells(1, 1).Value

gives a type mismatch. (run time error 13)

I'm totally confused !