View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Alan Beban[_3_] Alan Beban[_3_] is offline
external usenet poster
 
Posts: 130
Default whats wrong with my array?

joshashcraft wrote:
i have these two arrays both in one of my subs in my
worksheet, why won't they load the values? [snip]


The first (minor) problem is that ncount should go from 0 to 47 because
there are only 48 values in A3:A50.

The major problem is that you load each element of mynames with the
value from a3, then replace each with the value from a4, etc. so that
you end up with mynames having all its elements equal to the value from
A50. Use

Dim acell As Variant
Dim mynames(0 To 47)
Dim ncount As Integer
For Each acell In Range("a3:a50")
mynames(ncount) = acell.Value
ncount = ncount + 1
Next acell

Alan Beban


Dim acell As Variant
Dim mynames(0 To 49)
Dim ncount As Integer
For Each acell In Range("a3:a50")
For ncount = 0 To 49
mynames(ncount) = acell.Value
Next ncount
Next


Dim bcell As Variant
Dim mystatus(0 To 49)
Dim scount As Integer
For Each bcell In Range("b3:b50")
For scount = 0 To 49
mystatus(scount) = bcell.Value
Next scount
Next