Error not trapped - please help!!!
You can actually lose the lines
isA = False
isB = False
because the line
IsA = NOt r Is Nothing will set it to True or False, no need to
initialise
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"Bura Tino" wrote in message
...
"Bob Phillips" wrote in message
...
Bura,
An alternative approach
This helped!
Sub MySub()
Dim r As Range
Dim isA As Boolean
Dim isB As Boolean
isA = False
isB = False
On Error Resume Next
Set r = ActiveSheet.Range("AAA")
isA = Not r Is Nothing
Set r = ActiveSheet.Range("BBB")
isB = Not r Is Nothing
On Error GoTo 0
If isA Then
doAStuff
ElseIf isB Then
doBStuff
End If
End Sub
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"Bura Tino" wrote in message
...
Hi,
I'm going nuts trying to solve the following problem. If I execute the
following code when the active sheet has no named ranges, the first
error
is
trapped successfully, but the second one does not get trapped and the
execution breaks!
Sub MySub()
Dim r as Range
Dim isA as Boolean
Dim isB as Boolean
isA = False
isB = False
TryA:
On Error GoTo TryB
Set r = ActiveSheet.Range("AAA")
isA= True
GoTo Proceed
TryB:
On Error GoTo Proceed
Set r = ActiveSheet.Range("BBB")
isB = True
GoTo Proceed
Proceed:
If isAThen
doAStuff
ElseIf isB Then
doBStuff
End If
End Sub
Perhaps it's invalid to have 2 "On Error" statements? In any case, I
will
really appreciate your help!
Bura
|