I've written a function in Matlab that calculates the average growth rate for i.g. a companys profit. Profit is sometimes negative, so I've solved this "issue" with a couple of for-loops and if-statements, nothing fancy.
if y(i)<0 & y(i+1)<0
elseif y(i)>0 & y(i+1)>0
elseif y(i)<0 & y(i+1)>0
I would like to create a vba function in excel that does this, but I'm not familiar with vba. First and foremost I would like to be able to import the data into the vba function, obviously. In my Matlab function the input is a vector y, and the output is average growth.
So what I need help with is to import the data from and Excel spreadsheet to a vba function, followed by one output. The input varies in size, do I need paramarray? If someone could give me the first line of code it would be appreciated, the loops etc I can figure out myself.