I have been writing functions in vba for a template for designing heat exchangers. It returns #name errors when i try.

I have several functions I think i may have a problem with most of them. but they are written in such a way that

they depend on each other so that if the first returns an error the rest wont show anything.

The first is for calculating correction factor fc taken from Serth see code. I am stuck, see code.

Any body with any idea.

Thanks

I have several functions I think i may have a problem with most of them. but they are written in such a way that

they depend on each other so that if the first returns an error the rest wont show anything.

The first is for calculating correction factor fc taken from Serth see code. I am stuck, see code.

Code:

Option Explicit 'Correction Factor calculations for the LMTD 'source Robert R Serth, heat Transfer principles and applications. 'For any number of shell side passes and any even number of tube side passes as follows 'LMTD is calculated as ' N is the nymber of shell side passes Function Calcfc(Tis As Double, Tos As Double, Tit As Double, Tot As Double, N1 As Double, N2 As Double) As Double 'Correction Factor calculations for the LMTD 'source Robert R Serth, heat Transfer principles and applications. 'For any number of shell side passes and any even number of tube side passes as follows ' N is the nymber of shell side passes 'R P and alpha are ratios used to calculate the correction factor Dim R As Double, P As Double, S As Double, alpha As Double, n As Double Dim num As Double, den As Double, F As Double 'the numerators and denominators of the functions to ease writing the functions 'Where Ta (Tis)= inlet temperature of the shell-side fluid 'Tb (Tos) = outlet temperature of the shell-fluid 'ta (Tit= inlet temperature of the tube side fluid 'tb(Tot) = oulet temperature of the tube side fluid R = (Tis - Tos) / (Tot - Tit) P = (Tot - Tit) / (Tis - Tit) n = N1 * N2 alpha = ((1 - R * P) / (1 - P)) ^ (1 / n) If R = 1 Then S = P / (n - (n - 1) * P) num = (S * 2 ^ 0.5) den = (1 - S) * WorksheetFunction.Ln((2 - S * (2 - 2 ^ 0.5)) / (2 - S * (2 + 2 ^ 0.5))) F = num / den Else alpha = ((1 - R * P) / (1 - P)) ^ (1 / n) S = (alpha - 1) / (alpha - R) num = ((R ^ 2 + 1) ^ 0.5) * WorksheetFunction.Ln((1 - S) / (1 - R * S)) den = (R - 1) * WorksheetFunction.Ln((2 - S * (R + 1 - (R ^ 2 + 1) ^ (1 / 2))) / (2 - S * (R + 1 + (R ^ 2 + 1) ^ (1 / 2)))) F = num / den End If Calcfc = F End Function

Thanks

## Comment