ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   assigning values to an array (https://www.excelbanter.com/excel-programming/346529-assigning-values-array.html)

Juggernath[_4_]

assigning values to an array
 
Im new to VBA, is there some elegant way to assign number of values to an
array, for ex:

Dim A(0.3265, -1.07, -0.5339, 0.01569, -0.05165, 0.5475, -0.7361, 0.1844,
0.1056, 0.6134, 0.721) As Double
or
Dim A(11) as Double {0.3265, -1.07, -0.5339, 0.01569, -0.05165,
0.5475, -0.7361, 0.1844, 0.1056, 0.6134, 0.721}

instead of
A(1)=0.3265
A(2)=-1.07
....
....
....
....



Bob Phillips[_6_]

assigning values to an array
 
Dim A
A = [{0.3265, -1.07, -0.5339, 0.01569, -0.05165,0.5475, -0.7361, 0.1844,
0.1056, 0.6134, 0.721}]



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Juggernath" wrote in message
...
Im new to VBA, is there some elegant way to assign number of values to an
array, for ex:

Dim A(0.3265, -1.07, -0.5339, 0.01569, -0.05165, 0.5475, -0.7361, 0.1844,
0.1056, 0.6134, 0.721) As Double
or
Dim A(11) as Double {0.3265, -1.07, -0.5339, 0.01569, -0.05165,
0.5475, -0.7361, 0.1844, 0.1056, 0.6134, 0.721}

instead of
A(1)=0.3265
A(2)=-1.07
...
...
...
...





Dave Peterson

assigning values to an array
 
One mo

Dim myArr as Variant
dim iCtr as long
myArr = array(0.3265, -1.07, -0.5339, 0.01569, -0.05165, 0.5475, _
-0.7361, 0.1844, 0.1056, 0.6134, 0.721)

for ictr = lbound(myarr) to ubound(myarr)
msgbox myarr(ictr)
next ictr



Juggernath wrote:

Im new to VBA, is there some elegant way to assign number of values to an
array, for ex:

Dim A(0.3265, -1.07, -0.5339, 0.01569, -0.05165, 0.5475, -0.7361, 0.1844,
0.1056, 0.6134, 0.721) As Double
or
Dim A(11) as Double {0.3265, -1.07, -0.5339, 0.01569, -0.05165,
0.5475, -0.7361, 0.1844, 0.1056, 0.6134, 0.721}

instead of
A(1)=0.3265
A(2)=-1.07
...
...
...
...


--

Dave Peterson


All times are GMT +1. The time now is 11:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com