View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Character limit in Range Method

Why does the followihg work

x = Range("$A$1", "$A$2").Address
Debug.Print x


I don't think this line of code is doing what you think it is doing, mainly
because you picked a bad range (adjacent cells) to show what this line is
doing. Use this range instead...

x = Range("$A$1", "$A$23").Address

When you print x out, you will see this...

$A$1:$A$23

Notice the range contains 23 cells, not the two I think you thought it would
contain. That is why this doesn't work for you (notice I changed the cell
addresses so range is not a contiguous one)...

x = Range("$A$1", "$A$23", "$A$45").Address

VB doesn't know what you are trying to do with a third cell in there. The
way to do what I think you are trying to do is to not provide *separate*
arguments; but, rather, provide a single text string containing the three
cell addresses within it as the argument, like this...

x = Range("$A$1,$A$23,$A$45").Address

--
Rick (MVP - Excel)


"ExcelMonkey" wrote in message
...
Why does the followihg work

x = Range("$A$1", "$A$2").Address
Debug.Print x

But not the following:

x = Range("$A$1", "$A$2", "$A$3").Address
Debug.Print x

Thanks

EM