When posting code in VBForums, be sure to use [highlight=vb] Your code here [/highlight]. Also if you were to indent your code, you can see all the places where your if statement blocks are and more. Makes it 100 times easier to debug:

vb Code:
  1. Public Function Test(Val1 As Long, Val2 As Long) As Long
  2.  
  3.     If Val1 >= 500 Then
  4.          If Val2 >= 500 Then
  5.                Exit Function
  6.          End If
  7.     Else
  8.          Test = Val1 + Val2
  9.     End If
  10.  
  11. End Sub