Hi, Im having trouble assigning values to an array (nicely)
If you can assist or point me in the direction I would appretiate it.
Im writing a sheet where I want to dim an array, then assign variable
to the elements. The values are known in advance and I can set the
one at a time with the following code
MyArray(1) = 10: MyArray(2) = 27...
But I think i am looking for a vba version of something like..
Data 10,27,33,45,57
For valueCount = 1 to 5
Read AddValue(ValueCount)
Next ValueCount
I have the following code as an example of my current sollution,
but in fact I need to enter a minimum of 30 steps. I don't want t
read a range of cells for the values as ideally i want to keep in vba.
an example of my code
Dim AddValue(1 To 5) As Single
Dim ValueCount As Byte
Dim MyValue As Single
'---------------------[hmmm!]-----
AddValue(1) = 10
AddValue(2) = 27
AddValue(3) = 33
AddValue(4) = 45
AddValue(5) = 57
'----[ i'd like to assign these in loop with a data statement?? ]---
Do
ValueCount = ValueCount + 1
If ValueCount = 6 Then
ValueCount = 0
Exit Sub
Else
MyValue = MyValue + AddValue(ValueCount)
End If
Loop
End Sub
Any Assistance appretiated,
Regards
Skywa
--
Message posted from
http://www.ExcelForum.com