View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones[_2_] Norman Jones[_2_] is offline
external usenet poster
 
Posts: 421
Default Nightmare with Arrays

Hi Steve,

Perhaps, try:

Dim Arr As Variant

Arr = Range("L1:AE21").Value


---
Regards.
Norman


"Steve" wrote in message
...
I say perfect but I have created a test button with the following code:

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



"Sam Wilson" wrote:

Mark it right in case anyone else searches witha similar problem...

"Steve" wrote:

Perfect

Thanks Sam

"Sam Wilson" wrote:

Hi Steve - it's easy once you know how.

sub ArrayDemo()

dim A as string() 'or whatever datatype you want
dim i as integer

for i = 0 to 10
redim preserve A(i)
A(i) = Range("a1").offset(i,0).value
next i

end sub

Redim is the command to change the dimension of the array, preserve
means to
keep all the data in there.

Sam

"Steve" wrote:

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