electricpete
Technical User
Here's the situation.
I want to create a user-defined FUNCTION that manipulates several intermediate variables as complex variables. The excel complex functions (for example improduct, imsum, imexp) work on spreadsheet cells.
If I had a sub (instead of a function), I could just create my range variables, and then use a set statement to tie them to some remote unused corner of my spreadsheet, and then use them to store complex values (intermediate results).
BUT, I am using a function instead of a sub. Functions don't allow you to modify the spreadhseet by storing a value.
I could modify my function to call a subroutine, but then I'd have to pass all the other data long with it. Would certainly work, but it seems like a double-workaround
1 - I am having to store stuff in a spreadsheet cell, which I don't really want to do.
2 - I have having to create a sub and pass all my data to it, which I really want to do.
I could avoid these workaround and develop more straightforward code if I could simply create and manipulate a range (or single cell) variable within the function without tieing it to a spreadsheet. Is there a way to do this?
One solution I am considering is building my own userdefined data type for complex variables and then bulding my own set of primitive functions to manipulate these complex variables for complex multiplication, division etc. It would probably not be tremendously difficult. But I still would like to know if there is a way to use a range variable in a function without tieing to a spreadsheet.
I want to create a user-defined FUNCTION that manipulates several intermediate variables as complex variables. The excel complex functions (for example improduct, imsum, imexp) work on spreadsheet cells.
If I had a sub (instead of a function), I could just create my range variables, and then use a set statement to tie them to some remote unused corner of my spreadsheet, and then use them to store complex values (intermediate results).
BUT, I am using a function instead of a sub. Functions don't allow you to modify the spreadhseet by storing a value.
I could modify my function to call a subroutine, but then I'd have to pass all the other data long with it. Would certainly work, but it seems like a double-workaround
1 - I am having to store stuff in a spreadsheet cell, which I don't really want to do.
2 - I have having to create a sub and pass all my data to it, which I really want to do.
I could avoid these workaround and develop more straightforward code if I could simply create and manipulate a range (or single cell) variable within the function without tieing it to a spreadsheet. Is there a way to do this?
One solution I am considering is building my own userdefined data type for complex variables and then bulding my own set of primitive functions to manipulate these complex variables for complex multiplication, division etc. It would probably not be tremendously difficult. But I still would like to know if there is a way to use a range variable in a function without tieing to a spreadsheet.