View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Alan Beban[_2_] Alan Beban[_2_] is offline
external usenet poster
 
Posts: 783
Default VBA passing vector from spreadsheet to array

If the functions in the freely downloadable file at
http://home.pacbell.net/beban are available to your workbook, doing it a
cell at a time is built in to the Assign function:

Sub Main()
Dim arrDate() As Date
Assign MakeArray(Range("A1:J1"),1), arrDate
End Sub

The MakeArray function converts the input to a 1-dimensional array. If
the input is single-column range, the following also works:

Sub Main()
Dim arrDate() As Date
Assign Application.Transpose(Range("A1:A10")), arrDate
End Sub

Alan Beban

Tom Ogilvy wrote:

Sub Main()
dim arrDate(1 to 10) as Date
i = 0
for each cell in Range("A1:A10)
i = i + 1
arrDate(i) = Cell.Value
Next
Foo arrDate

End Sub

If you want to put values from a worksheet into other than a variant, you
have to do it a cell at a time.