RadBrad
10-12-2008, 12:49 PM
First, please understand that I am self-taught (I know!), I have searched this site for the answer and the questions on this site are well beyond my scope. I am having problems understanding how to call a sub or a function from another function.
I have this function that calculates the lineal inches of material used to make metal pipe:
Public Function SpiralInches(ByVal diameter As Single, ByVal length As Single)
Dim a As Single
Dim b As Single
a = diameter
b = length
Dim pi As Single
pi = 3.14159
SpiralInches = (a * pi) * b / 4.74
End Function
I would like to use this formula in other equations, for example, to divide it by 12 to get the footage. This is as far as I get:
Public Function SpiralLF(ByVal diameter As Single, ByVal length As Single)
SpiralLF() = SpiralInches() / 12
End Function
The error I get is that SpiralInches "Argument not optional".
The first function works fine by itself in the worksheet (i.e. I can assign a cell to each variable and it calculates properly) and I realize that I can add the first function to a cell and divide it by 12 at that point. But I really want to understand how to call the first function in a second one.
I've tried to make SpiralInches a sub, both Public and Private, I've tried dimensioning different variables within the second function, and I've tried a "Call" to the first function, all for naught. I can't seem to pass the results of the first function to the second one properly and any help with this would be GREATLY appreciated!
I am using Excel2003.
Thanks in advance!
Brad
I have this function that calculates the lineal inches of material used to make metal pipe:
Public Function SpiralInches(ByVal diameter As Single, ByVal length As Single)
Dim a As Single
Dim b As Single
a = diameter
b = length
Dim pi As Single
pi = 3.14159
SpiralInches = (a * pi) * b / 4.74
End Function
I would like to use this formula in other equations, for example, to divide it by 12 to get the footage. This is as far as I get:
Public Function SpiralLF(ByVal diameter As Single, ByVal length As Single)
SpiralLF() = SpiralInches() / 12
End Function
The error I get is that SpiralInches "Argument not optional".
The first function works fine by itself in the worksheet (i.e. I can assign a cell to each variable and it calculates properly) and I realize that I can add the first function to a cell and divide it by 12 at that point. But I really want to understand how to call the first function in a second one.
I've tried to make SpiralInches a sub, both Public and Private, I've tried dimensioning different variables within the second function, and I've tried a "Call" to the first function, all for naught. I can't seem to pass the results of the first function to the second one properly and any help with this would be GREATLY appreciated!
I am using Excel2003.
Thanks in advance!
Brad