Using a Sub instead of a Function
Using a Sub instead of a Function
(OP)
Hey guys,
I've got a Sub-routine that filters a table and performs a lookup selecting the appropriate data.
The Sub-routine was originally a function, yet the function was not working correctly.
My question is, why does the code run correctly when it is a sub-routine and not a function? And how do you apply a sub routine on one cell in excell to be used instead of a function?
Thanks
I've got a Sub-routine that filters a table and performs a lookup selecting the appropriate data.
The Sub-routine was originally a function, yet the function was not working correctly.
My question is, why does the code run correctly when it is a sub-routine and not a function? And how do you apply a sub routine on one cell in excell to be used instead of a function?
Thanks
RE: Using a Sub instead of a Function
I don't see much difference in calling a sub or a function, other than the way in which the arguments are passed and the return value is defined in a function.
Are all argument variables defined correctly according to their variable type?
We are more connected to everyone in the world than we've ever been before, except to the person sitting next to us. Lisa Gansky
RE: Using a Sub instead of a Function
RE: Using a Sub instead of a Function
It's a bit hard to say without seeing the code. If the sub writes values back to the spreadsheet at any stage it won't work as a function, so that's the most likely reason. There are some things that are a sort of "virtual write" which won't work in functions as well.
You can tie a sub to a worksheetchange event to get it working much like a UDF.
Doug Jenkins
Interactive Design Services
http://newtonexcelbach.wordpress.com/