Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Array function, two dimensions?? and worksheet arrays

Hi

example A
Dim A As Variant
A = Array(10,20,30)
B = A(2)
the above is straight from Excel help on array functions.

If have used two dimension arrays like this befo
example B
dim stuff(20,20) as integer

where stuff( var1, var2) gets me to where I want.

Q1) Can you 'do' exampleA in two dimensions?

Q2) the Excel text for example A says that 10,20,30 arglist are values.
Can what's inside the parenthesis be variable names containing values?

Q3) New topic:
I can't seem to find an example of how to specify an array of cells
for worksheet formulas (NOT a vba array)
will you provide a brief example?

Thanks much,

--
Neal Z
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Array function, two dimensions?? and worksheet arrays

Here is an example from "real life". I did not take anything out of this to make it easier to understand, so you may need to study
it for some time. This is a 2-dimension array example and it will show you how to load up both dimensions with variables from the
workbook.

Sub GetTeamExtract()
Dim MovingExtract(100, 16) As Variant
Dim E As Long
Dim Z As Long

Sheets("Team Data Table").Activate
Range("B7").Activate
E = 0
Do Until ActiveCell = "" 'loop through the list of Teams and copy their data
'to their data table

ActiveWorkbook.Names.Add Name:="Bookmark", RefersTo:=ActiveCell
N = ActiveCell.Text 'set variable to = Team names as it searches for their data
Range("G6:G286").Select 'go to the column in the table that holds the names
Cells.Find(What:=N, After:=Range("G6"), LookIn:=xlFormulas _
, LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False).Activate 'find the current Team in the table
ActiveCell.Select
ActiveCell.Offset(11, 66).Select 'select the 3 mo moving avg. for that Team
For Z = 0 To 15
MovingExtract(E, Z) = Selection 'load up array with values for each person
ActiveCell.Offset(0, 1).Select
Next
ActiveCell.Offset(0, -16).Select
E = E + 1
Application.Goto Reference:="Bookmark" 'go back to the list of Teams on the data page

ActiveCell.Offset(1, 0).Activate 'move down one cell

Loop 'loop to the next Team in the list

Sheets("Extract Averages").Activate
Range("Bookmark2").Select
ActiveCell.Offset(0, 1).Activate

For i = 0 To E
For Z = 0 To 15
ActiveCell.Offset(0, Z) = MovingExtract(i, Z)
Next
ActiveCell.Offset(1, 0).Activate 'move down one cell
Next 'i

End Sub

HTH
--
RMC,CPA


"Neal Zimm" wrote in message ...
Hi

example A
Dim A As Variant
A = Array(10,20,30)
B = A(2)
the above is straight from Excel help on array functions.

If have used two dimension arrays like this befo
example B
dim stuff(20,20) as integer

where stuff( var1, var2) gets me to where I want.

Q1) Can you 'do' exampleA in two dimensions?

Q2) the Excel text for example A says that 10,20,30 arglist are values.
Can what's inside the parenthesis be variable names containing values?

Q3) New topic:
I can't seem to find an example of how to specify an array of cells
for worksheet formulas (NOT a vba array)
will you provide a brief example?

Thanks much,

--
Neal Z


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Array function, two dimensions?? and worksheet arrays

Q1) Can you 'do' exampleA in two dimensions?

Yes, if you Dim the 2-D array as a variant. Only variants can hold
arrays... even arrays of arrays.

Q2) the Excel text for example A says that 10,20,30 arglist are values.
Can what's inside the parenthesis be variable names containing values?


No. Only values can be stored using the "Array" identifier. However, you
can store objects that are "pointers" to values. For example,

Dim arr(0 To 1) As Variant 'Variant array
Dim i As Integer
Dim j As Integer

arr(0) = Array(Range("a1"), Range("b2"), Range("c3")) 'Range of cells,
arr(1) = Array(Range("a2"), Range("b3"), Range("c4")) 'not their values

For i = 0 To 1
For j = 0 To 2
Debug.Print arr(i)(j).Value 'This works! Boy, was I surprised!
Next j
Next i

Q3) New topic:
I can't seem to find an example of how to specify an array of cells
for worksheet formulas (NOT a vba array)
will you provide a brief example?


Not quite sure what you mean here. Are you talking about array formulas in
Excel? Lookup the FormulaArray property in VBA help. Note that you have to
use R1C1 nomenclature in the formulae in this instance.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Array function, two dimensions?? and worksheet arrays

Q1) Can you 'do' exampleA in two dimensions?
No

You can do an array of arrays to simulate two dimensions, but you can't
create a two dimensional array in one command using the Array function.

You can do

Dim A as Variant
A = Evaluate("{1,2,3;4,5,6;7,8,9;10,11,12}")

will initialize a 4 x 3 array

Q2) the Excel text for example A says that 10,20,30 arglist are values.
Can what's inside the parenthesis be variable names containing values?
Yes
demo'd from the immediate window
f = 3
j = ll
h = 12
A = Array(f, j, h)
? a(2)
12
? a(0)
3


Q3) New topic:
I can't seem to find an example of how to specify an array of cells
for worksheet formulas (NOT a vba array)
will you provide a brief example?

ActiveCell.Formula = "=Sum(A1:A10,C1:C10)"

or
set rng = Range("A1:A0,C1:C10")
ActiveCell.Formula = "=Sum(" & rng.Address & ")"


--
Regards,
Tom Ogilvy


"Neal Zimm" wrote in message
...
Hi

example A
Dim A As Variant
A = Array(10,20,30)
B = A(2)
the above is straight from Excel help on array functions.

If have used two dimension arrays like this befo
example B
dim stuff(20,20) as integer

where stuff( var1, var2) gets me to where I want.

Q1) Can you 'do' exampleA in two dimensions?

Q2) the Excel text for example A says that 10,20,30 arglist are values.
Can what's inside the parenthesis be variable names containing

values?

Q3) New topic:
I can't seem to find an example of how to specify an array of cells
for worksheet formulas (NOT a vba array)
will you provide a brief example?

Thanks much,

--
Neal Z



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Array function, two dimensions?? and worksheet arrays

Thanks so much, I'll start to look at it.
--
Neal Z


"R. Choate" wrote:

Here is an example from "real life". I did not take anything out of this to make it easier to understand, so you may need to study
it for some time. This is a 2-dimension array example and it will show you how to load up both dimensions with variables from the
workbook.

Sub GetTeamExtract()
Dim MovingExtract(100, 16) As Variant
Dim E As Long
Dim Z As Long

Sheets("Team Data Table").Activate
Range("B7").Activate
E = 0
Do Until ActiveCell = "" 'loop through the list of Teams and copy their data
'to their data table

ActiveWorkbook.Names.Add Name:="Bookmark", RefersTo:=ActiveCell
N = ActiveCell.Text 'set variable to = Team names as it searches for their data
Range("G6:G286").Select 'go to the column in the table that holds the names
Cells.Find(What:=N, After:=Range("G6"), LookIn:=xlFormulas _
, LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False).Activate 'find the current Team in the table
ActiveCell.Select
ActiveCell.Offset(11, 66).Select 'select the 3 mo moving avg. for that Team
For Z = 0 To 15
MovingExtract(E, Z) = Selection 'load up array with values for each person
ActiveCell.Offset(0, 1).Select
Next
ActiveCell.Offset(0, -16).Select
E = E + 1
Application.Goto Reference:="Bookmark" 'go back to the list of Teams on the data page

ActiveCell.Offset(1, 0).Activate 'move down one cell

Loop 'loop to the next Team in the list

Sheets("Extract Averages").Activate
Range("Bookmark2").Select
ActiveCell.Offset(0, 1).Activate

For i = 0 To E
For Z = 0 To 15
ActiveCell.Offset(0, Z) = MovingExtract(i, Z)
Next
ActiveCell.Offset(1, 0).Activate 'move down one cell
Next 'i

End Sub

HTH
--
RMC,CPA


"Neal Zimm" wrote in message ...
Hi

example A
Dim A As Variant
A = Array(10,20,30)
B = A(2)
the above is straight from Excel help on array functions.

If have used two dimension arrays like this befo
example B
dim stuff(20,20) as integer

where stuff( var1, var2) gets me to where I want.

Q1) Can you 'do' exampleA in two dimensions?

Q2) the Excel text for example A says that 10,20,30 arglist are values.
Can what's inside the parenthesis be variable names containing values?

Q3) New topic:
I can't seem to find an example of how to specify an array of cells
for worksheet formulas (NOT a vba array)
will you provide a brief example?

Thanks much,

--
Neal Z





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Array function, two dimensions?? and worksheet arrays

Thanks, it's what the 'doctor' ordered.
--
Neal Z


"Eric White" wrote:

Q1) Can you 'do' exampleA in two dimensions?


Yes, if you Dim the 2-D array as a variant. Only variants can hold
arrays... even arrays of arrays.

Q2) the Excel text for example A says that 10,20,30 arglist are values.
Can what's inside the parenthesis be variable names containing values?


No. Only values can be stored using the "Array" identifier. However, you
can store objects that are "pointers" to values. For example,

Dim arr(0 To 1) As Variant 'Variant array
Dim i As Integer
Dim j As Integer

arr(0) = Array(Range("a1"), Range("b2"), Range("c3")) 'Range of cells,
arr(1) = Array(Range("a2"), Range("b3"), Range("c4")) 'not their values

For i = 0 To 1
For j = 0 To 2
Debug.Print arr(i)(j).Value 'This works! Boy, was I surprised!
Next j
Next i

Q3) New topic:
I can't seem to find an example of how to specify an array of cells
for worksheet formulas (NOT a vba array)
will you provide a brief example?


Not quite sure what you mean here. Are you talking about array formulas in
Excel? Lookup the FormulaArray property in VBA help. Note that you have to
use R1C1 nomenclature in the formulae in this instance.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Array function, two dimensions?? and worksheet arrays

As always Tom,
Concise, to the point, clever and accurate.
Thanks.
How can I get in touch with you outside of this bulletin board?
Snail mail or otherwise?
Many Thanks,
--
Neal Z


"Tom Ogilvy" wrote:

Q1) Can you 'do' exampleA in two dimensions?
No

You can do an array of arrays to simulate two dimensions, but you can't
create a two dimensional array in one command using the Array function.

You can do

Dim A as Variant
A = Evaluate("{1,2,3;4,5,6;7,8,9;10,11,12}")

will initialize a 4 x 3 array

Q2) the Excel text for example A says that 10,20,30 arglist are values.
Can what's inside the parenthesis be variable names containing values?
Yes
demo'd from the immediate window
f = 3
j = ll
h = 12
A = Array(f, j, h)
? a(2)
12
? a(0)
3


Q3) New topic:
I can't seem to find an example of how to specify an array of cells
for worksheet formulas (NOT a vba array)
will you provide a brief example?

ActiveCell.Formula = "=Sum(A1:A10,C1:C10)"

or
set rng = Range("A1:A0,C1:C10")
ActiveCell.Formula = "=Sum(" & rng.Address & ")"


--
Regards,
Tom Ogilvy


"Neal Zimm" wrote in message
...
Hi

example A
Dim A As Variant
A = Array(10,20,30)
B = A(2)
the above is straight from Excel help on array functions.

If have used two dimension arrays like this befo
example B
dim stuff(20,20) as integer

where stuff( var1, var2) gets me to where I want.

Q1) Can you 'do' exampleA in two dimensions?

Q2) the Excel text for example A says that 10,20,30 arglist are values.
Can what's inside the parenthesis be variable names containing

values?

Q3) New topic:
I can't seem to find an example of how to specify an array of cells
for worksheet formulas (NOT a vba array)
will you provide a brief example?

Thanks much,

--
Neal Z




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Array function, two dimensions?? and worksheet arrays



--
Regards,
Tom Ogilvy

"Neal Zimm" wrote in message
...
As always Tom,
Concise, to the point, clever and accurate.
Thanks.
How can I get in touch with you outside of this bulletin board?
Snail mail or otherwise?
Many Thanks,
--
Neal Z


"Tom Ogilvy" wrote:

Q1) Can you 'do' exampleA in two dimensions?
No

You can do an array of arrays to simulate two dimensions, but you can't
create a two dimensional array in one command using the Array function.

You can do

Dim A as Variant
A = Evaluate("{1,2,3;4,5,6;7,8,9;10,11,12}")

will initialize a 4 x 3 array

Q2) the Excel text for example A says that 10,20,30 arglist are values.
Can what's inside the parenthesis be variable names containing

values?
Yes
demo'd from the immediate window
f = 3
j = ll
h = 12
A = Array(f, j, h)
? a(2)
12
? a(0)
3


Q3) New topic:
I can't seem to find an example of how to specify an array of

cells
for worksheet formulas (NOT a vba array)
will you provide a brief example?

ActiveCell.Formula = "=Sum(A1:A10,C1:C10)"

or
set rng = Range("A1:A0,C1:C10")
ActiveCell.Formula = "=Sum(" & rng.Address & ")"


--
Regards,
Tom Ogilvy


"Neal Zimm" wrote in message
...
Hi

example A
Dim A As Variant
A = Array(10,20,30)
B = A(2)
the above is straight from Excel help on array functions.

If have used two dimension arrays like this befo
example B
dim stuff(20,20) as integer

where stuff( var1, var2) gets me to where I want.

Q1) Can you 'do' exampleA in two dimensions?

Q2) the Excel text for example A says that 10,20,30 arglist are

values.
Can what's inside the parenthesis be variable names containing

values?

Q3) New topic:
I can't seem to find an example of how to specify an array of

cells
for worksheet formulas (NOT a vba array)
will you provide a brief example?

Thanks much,

--
Neal Z






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
SUMPRODUCT function for two arrays. Array 1 contains text Payal Excel Worksheet Functions 1 June 19th 08 08:03 AM
SUMPRODUCT where arrays have different dimensions Chas Excel Discussion (Misc queries) 4 July 25th 07 09:30 PM
Array function, two dimensions?? Neal Zimm Excel Programming 0 October 1st 05 04:14 PM
Checking existence of array dimensions kdw Excel Programming 2 November 9th 04 08:32 PM
Checking Number of Dimensions In Array DigableP Excel Programming 2 February 28th 04 11:18 PM


All times are GMT +1. The time now is 06:19 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"