VBA Range question

remstadt

New Member
Joined
Jan 24, 2014
Messages
3
I am having trouble assigning to a range. Assume that I am passing a column range into the function. How can I modify the following to get it to assign a value to my_range?

Function assign_me(ByRef my_range As Range) As Double
Dim my_array As Variant
my_array = myrange.Value
For I = 1 To UBound(my_array, 1)
my_range(I, 1).Value = I
Next I
assign_me = 0#
End Function
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
If you are trying to call that function from a cell, it will not work.
 
Upvote 0
Is there a way to do it? I would like to make a function that is vector valued or array valued, and callable from the spreadsheet.
 
Upvote 0
Functions should just return values. Don’t attempt to manipulate other cells.
 
Upvote 0

Forum statistics

Threads
1,215,077
Messages
6,122,991
Members
449,094
Latest member
masterms

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top