help! function not obtaining cell values
The name of the ****ion is calcsoilpress but inside the function you're
referencing calsoilpress -- the names much match exactly -- the "c" is
missing!
"maweilian" wrote in message
...
Newbie question:
The simple VBA function below is not working. It is called by the
following
in the spreadsheet:
=calcsoilpress(D9,D10,'Soil Data'!D7,'Soil Data'!E7,D17)
(note: "Soil Data" is another worksheet in the same xls file)
When I add a breakpoint at the first "If-Then" line and examine the value
of
the variables, I discovered that some of the parameters had a value of
zero.
But the value of the cells are not zero! What is happening here?
Thanks in advance for any help!
Will
See code below:
Public Function calcsoilpress(soiltop As Double, soilbottom As Double,
soilwtdensitydry As Double, soilwtdensitywet As Double, waterdepth As
Double)
If waterdepth <= soiltop Then
calsoilpress = (soilbottom - soiltop) * soilwtdensitywet
End If
If waterdepth = soilbot Then
calsoilpress = (soilbottom - soiltop) * soilwtdensitydry
End If
If waterdepth soiltop And waterdepth < soilbot Then
calsoilpress = ((soilbottom - waterdepth) * soilwtdensitywet) +
((waterdepth - soiltop) * soilwtdensitydry)
End If
End Function
|