Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default array question

Want to do something like:

arrayvar = ("alpha","beta","delta")
For B = A(1) to A(3)
.......

Is this possible? Or do I have to do:
arrayvar = ("alpha","beta","delta")
For count = 1 to 3
B = A(count)

Also, for 3 variables, is this method faster than a if then else procedure?
Thank you.

Brent
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 301
Default array question

What's "A"?
How about:
For each thing in array("alpha","beta","delta")
'use "thing" here...
Next
Bob Umlas
Excel MVP

"Brent" wrote in message
...
Want to do something like:

arrayvar = ("alpha","beta","delta")
For B = A(1) to A(3)
......

Is this possible? Or do I have to do:
arrayvar = ("alpha","beta","delta")
For count = 1 to 3
B = A(count)

Also, for 3 variables, is this method faster than a if then else

procedure?
Thank you.

Brent



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default array question

sorry meant:

arrayvar = ("alpha","beta","delta")
For B = arrayvar(1) to arrayvar(3)

would the "for each" be quicker than an "if than else" for three variables?
Thank you.

Brent


"Bob Umlas" wrote:

What's "A"?
How about:
For each thing in array("alpha","beta","delta")
'use "thing" here...
Next
Bob Umlas
Excel MVP

"Brent" wrote in message
...
Want to do something like:

arrayvar = ("alpha","beta","delta")
For B = A(1) to A(3)
......

Is this possible? Or do I have to do:
arrayvar = ("alpha","beta","delta")
For count = 1 to 3
B = A(count)

Also, for 3 variables, is this method faster than a if then else

procedure?
Thank you.

Brent




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default array question

Did you mean something like:

dim ArrayVar as variant
dim iCtr as long
arrayvar = array("alpha","beta","delta")
for ictr = lbound(arrayvar) to ubound(arrayvar)
msgbox arrayvar(ictr)
next ictr


Brent wrote:

sorry meant:

arrayvar = ("alpha","beta","delta")
For B = arrayvar(1) to arrayvar(3)

would the "for each" be quicker than an "if than else" for three variables?
Thank you.

Brent

"Bob Umlas" wrote:

What's "A"?
How about:
For each thing in array("alpha","beta","delta")
'use "thing" here...
Next
Bob Umlas
Excel MVP

"Brent" wrote in message
...
Want to do something like:

arrayvar = ("alpha","beta","delta")
For B = A(1) to A(3)
......

Is this possible? Or do I have to do:
arrayvar = ("alpha","beta","delta")
For count = 1 to 3
B = A(count)

Also, for 3 variables, is this method faster than a if then else

procedure?
Thank you.

Brent





--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default array question


Others gave you the proper use of UBound / LBound.
Just to add if you wish a simple "1 to 3" as in your example:

Sub Demo()
Dim V As Variant
Dim J As Long
' 0-Based
V = Array("Alpha", "Beta", "Delta")
' 1-Based
With WorksheetFunction
V = .Transpose(.Transpose(V))
End With

For J = 1 To 3
MsgBox Format(J, "##: ") & V(J)
Next J
End Sub

--
HTH :)
Dana DeLouis
Windows XP & Office 2007


"Brent" wrote in message
...
sorry meant:

arrayvar = ("alpha","beta","delta")
For B = arrayvar(1) to arrayvar(3)

would the "for each" be quicker than an "if than else" for three
variables?
Thank you.

Brent


"Bob Umlas" wrote:

What's "A"?
How about:
For each thing in array("alpha","beta","delta")
'use "thing" here...
Next
Bob Umlas
Excel MVP

"Brent" wrote in message
...
Want to do something like:

arrayvar = ("alpha","beta","delta")
For B = A(1) to A(3)
......

Is this possible? Or do I have to do:
arrayvar = ("alpha","beta","delta")
For count = 1 to 3
B = A(count)

Also, for 3 variables, is this method faster than a if then else

procedure?
Thank you.

Brent






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
array question Mona Excel Discussion (Misc queries) 2 March 23rd 10 08:41 PM
Array Question Larry L Excel Discussion (Misc queries) 16 January 20th 09 08:25 AM
For Each Array Question mvyvoda Excel Programming 1 June 12th 06 06:34 PM
array question Gary Keramidas Excel Programming 4 October 18th 05 05:45 AM
Array question Jim Simpson Excel Programming 3 September 22nd 04 04:40 AM


All times are GMT +1. The time now is 04:29 PM.

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"