Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default rng(1,1) syntax doesn't work for set rng = arange.columns(1)

Not sure this is a totally satisfactory explanation, but here's my
best guess. Look at

? Range("B2:B5").Cells.Count, Range("B2:B5").Columns(1).Count
4 1

When you reference the column property, it returns a unit rather
than a range of cells.

Since the

rng(1, 1)

syntax is shorthand for

rng.item(rowindex, columnindex)

syntax, my best guess is that specifying a rowindex is ambiguous and
therefore returns the error.

In article ,
"Tim Zych" wrote:

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default rng(1,1) syntax doesn't work for set rng = arange.columns(1)

Since the

rng(1, 1)

syntax is shorthand for

rng.item(rowindex, columnindex)


That's exactly my understanding too. I posted another
sample in response to Alan. What am I missing?


-----Original Message-----
Not sure this is a totally satisfactory explanation, but

here's my
best guess. Look at

? Range("B2:B5").Cells.Count, Range("B2:B5").Columns

(1).Count
4 1

When you reference the column property, it returns a unit

rather
than a range of cells.

Since the

rng(1, 1)

syntax is shorthand for

rng.item(rowindex, columnindex)

syntax, my best guess is that specifying a rowindex is

ambiguous and
therefore returns the error.

In article ,
"Tim Zych" wrote:

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

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default rng(1,1) syntax doesn't work for set rng = arange.columns(1)

What you're missing is that Range("B2:X5").Column(1) is not the same as
Range("B2:X5).

Range("whatever") and Range("whatever").Areas(n) are Range Objects that
are also Collection Objects; in this case collections of cells.
Range("whatever").Columns and Range("whatever").Rows are also Range
Objects that are Collection Objects; but in this case collections of
columns and rows, respectively.

Thus the Item Property, which refers to the items in a collection, after
Set rng = Range("whatever").Columns(1) is looking for a single index
number; e.g., in rng(3) the reference is to the 3rd item in the
collection of columns, i.e., the 3rd column of the range (and since
range indices refer to cells, columns, etc. outside the stated
range--e.g., after Set rng = Range("A1"), rng(2,2) is meaningful to
refer to Cell B2 even though it's outside of rng--rng(3) in the above
case refers to the 3rd column even though that is outside the one-column
range).

In short (somewhat belatedly), after
Set rng = Range("B2:X5").Columns(1), rng(1,1), which is indeed shorthand
for rng.Item(1,1) is failing because the Item Property applied to a
collection of columns is looking for a single index number, the number
of the column.

Alan Beban

Tim Zych wrote:
Since the

rng(1, 1)

syntax is shorthand for

rng.item(rowindex, columnindex)



That's exactly my understanding too. I posted another
sample in response to Alan. What am I missing?



-----Original Message-----
Not sure this is a totally satisfactory explanation, but


here's my

best guess. Look at

? Range("B2:B5").Cells.Count, Range("B2:B5").Columns


(1).Count

4 1

When you reference the column property, it returns a unit


rather

than a range of cells.

Since the

rng(1, 1)

syntax is shorthand for

rng.item(rowindex, columnindex)

syntax, my best guess is that specifying a rowindex is


ambiguous and

therefore returns the error.

In article ,
"Tim Zych" wrote:


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


.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Arange sorted data in multiple columns Unknown Excel Discussion (Misc queries) 6 September 6th 07 03:59 AM
Help to adapt Formula syntax to work with Visible Filtered Cells Sam via OfficeKB.com Excel Worksheet Functions 6 September 16th 05 11:42 PM
Help to adapt Formula syntax to work with Dynamic Named Ranges Sam via OfficeKB.com Excel Worksheet Functions 13 April 29th 05 12:36 AM
arange dates kabeer Excel Discussion (Misc queries) 1 April 8th 05 03:15 AM
rng(1,1) syntax doesn't work for set rng = arange.columns(1) Alan Beban[_3_] Excel Programming 2 September 30th 03 11:29 PM


All times are GMT +1. The time now is 11:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"