Why is this a Type Mismatch error?
However, instead of relying on string comparisons, you can also determine
what sort of data type you get back from the Value property, and if it's an
error you can take further action.
1) Check the Value (which is of type Variant) with VarType(...) = vbError,
or simply use IsError()
2) You can then use one of the constants from the XlCVError enumeration to
figure out exactly which error you've got.
Cheers,
/MP
"Damon" wrote:
Thank you Norman that has fixed it!
"Norman Jones" wrote:
Hi Damon,
Try replacing:
If ActiveCell.Value = "#N/A" Then
with
If ActiveCell.Text = "#N/A" Then
---
Regards,
Norman
"Damon" wrote in message
...
Can anybody please tell me why I am getting a type mismatch error on the
first line of this seemimgly simple bit of code? (i am using excell 2000)
Sub NAdelete()
If ActiveCell.Value = "#N/A" Then
ActiveCell.Offset(0, 1).Activate
ActiveCell.Offset(0, -1).EntireRow.Delete
Else
ActiveCell.Offset(0, 1).Activate
End If
End Sub
Thank you in advance!
|