i have a workbook that contains two cells named distance and height,
contained in these cells are two numbers (doubles). In another cell
I have a formula which calls a function boomLength(radius, height)
with the following code contained in it:
---------------------------------------------------------------------
Public Function boomLength(radius As Double, height As Double) As
Double
boomLength = (radius ^ 2 + height ^ 2) ^ 0.5
End Function
---------------------------------------------------------------------
The above code works fine and outputs the value of the longest side
of a triangle, but I would also like the function to add some text
into a cell next to the answer, with that code added it looks as
follows:
---------------------------------------------------------------------
Public Function boomLength(radius As Double, height As Double) As
Double
Cells(1, 2) = "insert text here"
boomLength = (radius ^ 2 + height ^ 2) ^ 0.5
End Function
---------------------------------------------------------------------
Unfortuanatly as soon as I add the line of code to print the text
the cell which calls the function and displays the answer just gives
a #VALUE! error, when asking for help on this error it sais "Make
sure the function is not using an incorrect argument". For the life
of me I cant find the problem. Both lines of code work seperatly
but as soon as they are put together everything goes pair shaped :(
Im sure i am missing something simple and am going to kick myself,
but until then im stuck!!! Any help would be gratly appreciated. Soz
for the long post but i didnt want to supply insufficient
information.