View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
r r is offline
external usenet poster
 
Posts: 125
Default Test for Error in cells


"LeeL" wrote:

I am trying to test for letters or numbers within a cell.
I cannot get the Iserror to work correctly, nonerror is ok, but if it is an
error, i cannot get True, i get a VBA error.

Can someone please help?

a1$ = Mid(Range("a1").Text, 2, 1)
b1$ = Mid(Range("b1").Text, 3, 1)
If IsError(a1 * b1) Then
MsgBox "error"
Else: MsgBox "nonerror"
End If



Sub test()
Dim a1$, b1$, v

a1$ = Mid(Range("a1").Text, 2, 1)
b1$ = Mid(Range("B1").Text, 3, 1)

'....
On Error Resume Next

v = a1$ * b1$

If Err Then
Err.Clear
MsgBox "Error"
Else
MsgBox "Not Error"
End If

On Error GoTo 0

End Sub

regards
r

Il mio ultimo lavoro ...
http://excelvba.altervista.org/blog/...ternative.html