Hi
I'm new to VB and think I'm missing something basic here. I've written a function called Test2, but whenever I type "=Test2(670)" into my worksheet for example, I get the #Name? error.
Do I need to set up/declare the variable somewhere else as well?
Any advice much appreciated. Thanks.
Test2 Code:
Option Explicit Function Test2(Tinit As Double) Dim cp1() As Double ' calculate specific heat If (Tinit < 600) Then cp1 = (425 + (0.773 * Tinit) - (1.69 * 10 ^ -3 * (Tinit ^ 2)) + (2.22 * 10 ^ -6 * (Tinit ^ 3))) ElseIf ((600 <= Tinit) And (Tinit < 735)) Then cp1 = 666 + 13002 / (738 - Tinit) ElseIf ((735 <= Tinit) And (Tinit < 900)) Then cp1 = (545 + 17820 / (Tinit - 731)) ElseIf ((900 <= Tinit) And (Tinit <= 1200)) Then cp1 = 650 End If Test2 = cp1 End Function




Reply With Quote