IsError?

charlie79

Board Regular
Joined
Feb 27, 2002
Messages
97
Can I use the excel IsError function in VBA code? I have a refresh timer running every five secs, and from time to time, some cells contain !NULL#. This is a result of a add-in bug. I am checking for the string "!NULL#" right now, but it doesn't seem to work. I'm using something like:
if cells(6, 1).value = "!NULL#" then
do something
else
do something else
end if
Any ideas?
 
No it will not
MyType = TypeName(Cells(6, 1).Value)
Notice typename.
Cells are variants by default.
A variant can contain most any datatype.
If Cells(6, 1).Value contained a string "Error" then in the above code:
MyType would = "String" not "Error".
TypeName is a VB function which returns the data type of the variant.
In this case an Error

Tom
This message was edited by TsTom on 2002-04-02 08:09
 
Upvote 0

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Great! Thanks for the explanation Tom. I'm not the type of person who takes a solution and runs, I like to understand what I'm using. Thanks again!

:)
 
Upvote 0
Tom, or anyone, after running that code from Tom I'm getting an Invalid Qualifier error. It points to the
myType = TypeName(Cells(8, 1).Value)
line (highlighting typename). Is this a problem with my variant myType, it is declared as a String. ???
 
Upvote 0
Hey

The function TypeName returns a string.
I'm using Office 2000.
I do not know if this function came with earlier version of VB/VBA?

I tested the code as such:

Placed this formula in A1 to generated the #NULL! error.
=SUM(B1 C1)

Ran this code to see what would be assigned.

Sub SeeError()
Dim MyType As String
Dim CheckCell as Boolean

CheckCell = IsError(Cells(1, 1).Value)
MyType = TypeName(Cells(1, 1).Value)

Debug.Print "CheckCell = " & CheckCell
Debug.Print "MyType = " & MyType

'CheckCell = True
'MyType = "Error"
End Sub

It works for me!
Tom
This message was edited by TsTom on 2002-04-02 11:07
 
Upvote 0

Forum statistics

Threads
1,215,102
Messages
6,123,099
Members
449,096
Latest member
provoking

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top