E
ExcelMonkey
I have a routine which is using error handling to handle the character limits
in a range variable. The first part of my routine works fine (Part1). Later
on in the routine (Part2) I try to do something similar. However, the code
does not seem to generate an error when I test for If Err.Number <> 0. This
should be generating a 1004 error has I am trying to append the range and
effectively breaching the character limit on the range variable. The code
simply keeps running, does not fail and does not error handle. The
Err.Number is always = 0. However when I test the length of the variables in
the Immediate Window I get the following:
?LEN(Range(FinalArray(x - 1)).Address)
12
?Len(previousunion)
255
?LEN(Union(Range(previousunion), Range(FinalArray(x - 1))).Address)
255
This implies that the third test should be 12 + 255 = 277 not 255. Why is
this not generating an error? Is it because of the error handling above in
Part 1?
'Part 1
On Error Resume Next
t = Len(CurrentString)
Set rng2 = Range(CurrentString)
If Err.Number <> 0 Then
'do something
End if
On Error GoTo 0
'**********************************
'Part 2
On Error Resume Next
t = Len(previousunion)
Set rngUnion1 = Union(Range(previousunion), Range(FinalArray(x - 1)))
If Err.Number <> 0 Then
'Do something
End if
On Error GoTo 0
Thanks
EM
in a range variable. The first part of my routine works fine (Part1). Later
on in the routine (Part2) I try to do something similar. However, the code
does not seem to generate an error when I test for If Err.Number <> 0. This
should be generating a 1004 error has I am trying to append the range and
effectively breaching the character limit on the range variable. The code
simply keeps running, does not fail and does not error handle. The
Err.Number is always = 0. However when I test the length of the variables in
the Immediate Window I get the following:
?LEN(Range(FinalArray(x - 1)).Address)
12
?Len(previousunion)
255
?LEN(Union(Range(previousunion), Range(FinalArray(x - 1))).Address)
255
This implies that the third test should be 12 + 255 = 277 not 255. Why is
this not generating an error? Is it because of the error handling above in
Part 1?
'Part 1
On Error Resume Next
t = Len(CurrentString)
Set rng2 = Range(CurrentString)
If Err.Number <> 0 Then
'do something
End if
On Error GoTo 0
'**********************************
'Part 2
On Error Resume Next
t = Len(previousunion)
Set rngUnion1 = Union(Range(previousunion), Range(FinalArray(x - 1)))
If Err.Number <> 0 Then
'Do something
End if
On Error GoTo 0
Thanks
EM