Worksheet Names to Variant array

  • Thread starter Alasdair Stirling
  • Start date
A

Alasdair Stirling

I have a worksheet with the numbers 1 to 8 in range d8:g9 and have named
range d8:g8 "SheetNumbers" and d8:g8 "SheetNumbers2". I have also defined
two workbook names as follows: "NameNumbers" ={1,2,3,4} and "NameNumbers2"
={1,2,3,4;5,6,7,8}.

I have a vba procedure as follows:

Sub alpha()

Dim X As Variant, Y As Variant

X = Sheet1.Range("SheetNumbers2")
Y = [NameNumbers2]

Debug.Print LBound(X, 1); UBound(X, 1)
Debug.Print LBound(Y, 1); UBound(Y, 1)

End Sub

That produces the following result in the intermediate window:

1 2
1 2

So far so good, but I also have another proceedure as follows:

Sub bravo()

Dim X As Variant, Y As Variant

X = Sheet1.Range("SheetNumbers")
Y = [NameNumbers]

Debug.Print LBound(X, 1); UBound(X, 1)
Debug.Print LBound(Y, 1); UBound(Y, 1)

End Sub

That produces the following result in the intermediate window:

1 1
1 4

For some reason Excel seems to interpret NameNunbers2 as an array of 2 rows
and 4 columns, but interprets NameNumbers as an array of 4 rows and 1 column.
Does anybody know why?
 
R

Ronx

I suggest you post in an Excel newsgroup. Excel ranges have little to
do with FrontPage (unless you intend to use the worksheet as a web
database).
 

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