Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50103

[SOLVED] VBA Userdefined Function returns #Value! error

$
0
0
Hi!
I'm new to VBA Programming .. !
Please have a look on the code given below. When I call this function it shows #Value! error when value in the variable Q < 8.
I've also attached a file for your reference. Please help me out as I'm not able to resolve this issue. :confused:

Thanks! in advance

Regards
Code:

Dim n As Double
Dim velocity As Double
Dim discharge As Double
Dim ddepth As Double

Public Function CDepth(Q, V, Slope, Mcoeff) As Double
discharge = Q
s = Slope
velocity = V
n = Mcoeff

HR = ((V * n) / (s ^ 0.5)) ^ (3 / 2)

area = discharge / velocity
Dim c As Double
Dim b As Double
Dim a As Double

a = 2
b = area - HR
c = area

ddepth = (b + Sqr((b ^ 2) - 4 * a * c)) / (2 * a)

CDepth = ddepth

End Function


CDepth.xlsm

Viewing all articles
Browse latest Browse all 50103

Trending Articles