ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   rng(1,1) syntax doesn't work for set rng = arange.columns(1) (https://www.excelbanter.com/excel-programming/278423-re-rng-1-1-syntax-doesnt-work-set-rng-%3D-arange-columns-1-a.html)

Vasant Nanavati[_2_]

rng(1,1) syntax doesn't work for set rng = arange.columns(1)
 
Hi Tim:

A wild guess, but possibly a single column is internally defined to be
one-dimensional, causing a conflict with the double index.

?Range("B2:X5").Columns(1).Address
$B$2:$B$5
?Range("B2:B5")(1).Address
$B$2

However:

?Range("B2:X5").Columns(1)(1).Address
$B$2:$B$5

It seems that once you define a range explicitly as a column, the unit
becomes the column and not a cell within the column. I'm not expressing the
concept very well, but I'm sure you get the gist.

Regards,

Vasant.

"Tim Zych" wrote in message
...
Anybody know why this doesn't work?

Dim rng As Range
Set rng = Range("B2:X5").Columns(1)
Debug.Print rng.Address '<- this works
Debug.Print rng(1, 1).Address '<-this doesn't

Yes, rng.cells(1,1) does work. What's up with this?

XL2000, Win2000





All times are GMT +1. The time now is 01:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com