worksheet error checking

A

AlexD

How could I check from VB whether a spreadsheet has any
errors?

I'm trying to use
If xlbook.Worksheets(1).Cells(i, j) = "#DIV/0!" Then ...
but the type is mismatched.

The following is not working as well
If xlbook.Worksheets(1).IsError(Cells(i, j)) = True ...

It's a good function (ISERROR) for a spreadsheet but
cannot be used like this in VB(no property).

Can anybody advise anything?

Thanks
 
A

AlexD

Thanks, I've got it.
I'm using now:

If IsError(xlbook.Worksheets(1).Cells(i, j)) = True ...

It's working
 
C

Carlos

Alex

If IsError(xlbook.Worksheets(1).Cells(i, j)) is the same

If IsError(xlbook.Worksheets(1).Cells(i, j)) =True

If Not(IsError(xlbook.Worksheets(1).Cells(i, j))) is the same

If IsError(xlbook.Worksheets(1).Cells(i, j)) =False
 
B

Bob Phillips

Alex,

You could use something like

Dim fError As Boolean
Dim cell As Range

For Each cell In Selection
With cell
fError = False
On Error Resume Next
fError = (.Value = CVErr(xlErrDiv0) Or _
.Value = CVErr(xlErrNA) Or _
.Value = CVErr(xlErrName) Or _
.Value = CVErr(xlErrNull) Or _
.Value = CVErr(xlErrNum) Or _
.Value = CVErr(xlErrRef) Or _
.Value = CVErr(xlErrValue))
End With
Debug.Print fError
Next cell

but it may get a bit onerous with a big range

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
A

AlexD

Thanks, Carlos.

You are right.
-----Original Message-----
Alex

If IsError(xlbook.Worksheets(1).Cells(i, j)) is the same

If IsError(xlbook.Worksheets(1).Cells(i, j)) =True

If Not(IsError(xlbook.Worksheets(1).Cells(i, j))) is the same

If IsError(xlbook.Worksheets(1).Cells(i, j)) =False




.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top