Testing For Range Variable Limit

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
 
E

ExcelMonkey

So I can pass a cell address string longer than 255 char to the Range Method
and force an error stmt by setting a range variable to this. But I cannot
force an error statmt by setting a range variable to a bunch of ranges
wrapped in a Union Method which include a 255 char breach within a Range
Method?

This is really annoying.

Does the Range Method in Excel 2007 VBA still have the 255 char limit?

Thanks

EM
 

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