Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Worksheet names to variant arrays

I have a worksheet with the numbers 1 to 8 in range d8:g9 and have named
range d8:g8 "SheetNumbers" and d8:g9 "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 procedure 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 a single column array of 4 rows.
Does anybody know why?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Worksheet names to variant arrays

Because that is the way you created them. By adding a semi-colon after the 4
in NameNumbers2, you created a second dimension to the array.

--
HTH

Bob Phillips

"Alasdair Stirling" wrote in
message ...
I have a worksheet with the numbers 1 to 8 in range d8:g9 and have named
range d8:g8 "SheetNumbers" and d8:g9 "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 procedure 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 a single column array of 4

rows.
Does anybody know why?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Worksheet names to variant arrays

The question is why does excel interpret NameNumbers as a single column array
of 4 rows, rather than an array of 1 row and foru columns?

"Bob Phillips" wrote:

Because that is the way you created them. By adding a semi-colon after the 4
in NameNumbers2, you created a second dimension to the array.

--
HTH

Bob Phillips

"Alasdair Stirling" wrote in
message ...
I have a worksheet with the numbers 1 to 8 in range d8:g9 and have named
range d8:g8 "SheetNumbers" and d8:g9 "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 procedure 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 a single column array of 4

rows.
Does anybody know why?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Worksheet names to variant arrays

It interprest NameNumbers as a 1 dimensional array. You are interpreting
it as four rows. Excel interprets it as 4 columns (A horizontal array is
the common term).

VBA doesn't care. It sees it as a 1 dimensional array and a one dimensional
array has neither rows nor columns - just 4 elements.

To see Excels interpretation, select A1:A4 and enter

=NameNumbers
Ctrl+shift+Enter

and you will see a column of 1's (the first element of the array listed 4
times)

Select B1:E1 and do the same. You will see 1 2 3 4

--
Regards,
Tom Ogilvy



"Alasdair Stirling" wrote in
message ...
The question is why does excel interpret NameNumbers as a single column

array
of 4 rows, rather than an array of 1 row and foru columns?

"Bob Phillips" wrote:

Because that is the way you created them. By adding a semi-colon after

the 4
in NameNumbers2, you created a second dimension to the array.

--
HTH

Bob Phillips

"Alasdair Stirling" wrote

in
message ...
I have a worksheet with the numbers 1 to 8 in range d8:g9 and have

named
range d8:g8 "SheetNumbers" and d8:g9 "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 procedure 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 a single column array of

4
rows.
Does anybody know why?






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
Arrays/Names in spreadsheet. Dan Excel Discussion (Misc queries) 1 October 5th 08 10:07 AM
Arrays & Defined Names Bec Excel Discussion (Misc queries) 2 April 9th 07 09:38 AM
Linking arrays and Worksheet names gsimmons2005 Excel Worksheet Functions 2 August 18th 05 04:54 PM
Passing variant arrays to C/C++ dll's agarwaldvk[_35_] Excel Programming 0 October 18th 04 01:33 AM
Excel - DotNet - Variant Arrays as Params Paul S Bryant Excel Programming 7 December 3rd 03 11:18 AM


All times are GMT +1. The time now is 02:52 PM.

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

About Us

"It's about Microsoft Excel"