Thread: Array Values
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Rech Jim Rech is offline
external usenet poster
 
Posts: 2,718
Default Array Values

If I wanted to populate an array of integers from the range A1 to AP1, some
or all of which may have entries, I'd do it like this:

Sub a()
Dim MyArray() As Integer
Dim Cell As Range, Counter As Integer
For Each Cell In Range("A1:AP1").SpecialCells(xlCellTypeConstants)
Counter = Counter + 1
ReDim Preserve MyArray(1 To Counter)
MyArray(Counter) = Cell.Value
Next
End Sub

--
Jim Rech
Excel MVP
"Michael168 " wrote in message
...
|I declare a dynamic array but don't know how to assign the cells.value
| to the wheel
| I use columns A1:AP1 to let the user key in each individual number.
| From the range that have numbers, I use the counter as array size.
| e.g
|
| Sub Lwheel()
|
| ict = WorksheetFunction.CountA(Range("A1:AP1"))
| Dim wheel()
| Redim Wheel(0 To ict)
|
| Example the user key in A1=1,A2=2,A3=3,A4=4,A5=5,A6=6,A7=7,A8=8
|
| So the array becomes as below;
|
| Wheel(0)=A1 # 1
| Wheel(1)=A2 # 2
| Wheel(2)=A3 # 3
| Wheel(3)=A4 # 4
| Wheel(4)=A5 # 5
| Wheel(5)=A6 # 6
| Wheel(6)=A7 # 7
| Wheel(7)=A8 # 8
|
| My questions is how to assign the individual cells.value to wheel (0)
| until wheel(7)?
|
|
| End Sub
|
| Regards
| Michael
|
|
| ---
| Message posted from http://www.ExcelForum.com/
|