AndrewWolford
MIS
Hi everyone,
I've written a small function in excel that reads in a range into a dynamic array but I can't figure out how to make the range "user specified" and can't figure out how to call the function from a cell in excel.
Here's my code so far:
Sub testfunction()
Dim myCell As Range
Dim testarray() As Double
Dim i As Integer
i = 1
For Each myCell In Range("B1:B9"
ReDim Preserve testarray(i)
testarray(i) = myCell.Value
i = i + 1
Next myCell
End Sub
I need the range("B1:B9"
to be a range passed by the user instead of a static range. Also, how can I then call this functin from a cell. I thought I could go " =testfunction(B1:B100)" but that doesnt work. Thank you for any help!
-Andrew
I've written a small function in excel that reads in a range into a dynamic array but I can't figure out how to make the range "user specified" and can't figure out how to call the function from a cell in excel.
Here's my code so far:
Sub testfunction()
Dim myCell As Range
Dim testarray() As Double
Dim i As Integer
i = 1
For Each myCell In Range("B1:B9"
ReDim Preserve testarray(i)
testarray(i) = myCell.Value
i = i + 1
Next myCell
End Sub
I need the range("B1:B9"
-Andrew