View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
Sam Wilson Sam Wilson is offline
external usenet poster
 
Posts: 523
Default Nightmare with Arrays


It should be "dim |List() as variant" , you need the brackets in the
declaration for an array


"Steve" wrote:

Norman

Essentially I want to run across a sheet putting values into an array. Then
move down a line and run across again, this time adding the value to the
value in the array.

e.g.

0 0 0 0 0
1 0 0 1 1
2 0 0 0 2

there are 2 columns to check. I need to do this for each customer in another
list.

I have the following code from Sam which I have put into a test button.
However, this throws up a Run time error 13 - Type Mismatch error.

Private Sub CommandButton1_Click()

Dim lList As Variant
Dim iCol, i As Integer

Worksheets("Export").Select

For iCol = 12 To 31

For i = 0 To 20
ReDim Preserve lList(i)
lList(i) = Cells(2, iCol).Value
Next i

Next iCol

End Sub

"Norman Jones" wrote:

Hi Steve,

You should stay in the original thread.

Try to explain precisely what data is to
be loaded into the array and what you
wish to do with the array.

Note, however, that a range may be
loaded directly into an array, e.g.:

Dim arr As Variant

arr = Range("A1:B10").Value



---
Regards.
Norman


"Steve" wrote in message
...
Hi

I did write yesterday but with no real success.

I am trying to put a number of values in an array by looping through some
cells.

I'm having difficulty as I don't know how long the array will be nor can I
sem to add to it.

I have tried the following so far.

A=array() - create an empty array
A(0) = cells(count,1).value
A(1) = cells(count,2).value
etc etc

I have looked at similar code that puts cell information into an array and
I
think it's the creation of a blank array that is the problem.

The trouble is that I do not know how big the array is going to be.

Any guidance would be appreciated.

Thanks

Steve