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
|