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:
  1. Option Explicit
  2.  
  3. Function Test2(Tinit As Double)
  4.                                          
  5.   Dim cp1() As Double
  6.    
  7.   ' calculate specific heat
  8.     If (Tinit < 600) Then
  9.         cp1 = (425 + (0.773 * Tinit) - (1.69 * 10 ^ -3 * (Tinit ^ 2)) + (2.22 * 10 ^ -6 * (Tinit ^ 3)))
  10.     ElseIf ((600 <= Tinit) And (Tinit < 735)) Then
  11.         cp1 = 666 + 13002 / (738 - Tinit)
  12.     ElseIf ((735 <= Tinit) And (Tinit < 900)) Then
  13.         cp1 = (545 + 17820 / (Tinit - 731))
  14.     ElseIf ((900 <= Tinit) And (Tinit <= 1200)) Then
  15.         cp1 = 650
  16.     End If
  17.        
  18. Test2 = cp1
  19.      
  20. End Function