Modify input range to a function

axed

New Member
Joined
Aug 29, 2010
Messages
15
Hi,

I have a vba function, I am giving it a matrix as input. I am however unable to modify the matrix within the function. Below is my function . Could you please help.

Function MaxDrawdown(A As Range)
A(2) = 0 'This does not work for me
End Function

Thanks in advance.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
If you are using that as a user-defined function (a function used in a cell formula), that won't work. With some odd exceptions, all a UDF can do is return a value to the cell in which it appears.
 
Upvote 0
Thanks, yea, its a UDF. Do you think the only way to go about this it is to create a copy of the input range matrix and then modify the copy. Since I need to perform operations on the input matrix to return output.
 
Upvote 0
You can read it into an array:
Code:
Function MaxDrawdown(A As Range)
    Dim avd As Variant
    
    avd = A.Value
    avd(1, 2) = 0
    ' carry on ...
End Function
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,946
Latest member
JoseDavid

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