View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Working with range

Think you shifted from talking about Arrays to talking about ranges.

ThisRange(1) would raise an error since ThisRange is a two dimensional
array. And an array itself doesn't have any properties such as Item.

--
Regards,
Tom Ogilvy

"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Francois,

You are using the UBound function incorrectly:

ThisRange = Range("A2:N81")
MsgBox UBound(ThisRange, 1) 'returns 80
MsgBox UBound(ThisRange, 2) 'returns 14

ThisRange(1) is the first cell, cell A2.

ThisRange(1) is shorthand for ThisRange.Item(1)

HTH,
Bernie
MS Excel MVP


"François" wrote in message
...
Hello

I have some problems dealing with the arrays.
Here the code

ThisRange = Range("A2:N81")
It supposed to be a array of 2 dimensions of type variant
So If I do uBound(ThisRange) I get 80 which seems to be right (80 rows).
But if I asked uBound(ThisRange(1)) which is supposed to give me the

number
of elements coming from the columns I get an error 9 "Subscript out of

range".

What is wrong in my code ?

Thanks
François