Announcement

Collapse
No announcement yet.

Public Function VBA #VALUE Error

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Public Function VBA #VALUE Error

    Hi,

    I have created a simple Public Function (to be expanded) but want to make sure I can get the call in excel working. Here is the code:

    Code:
    Public Function Wind (Direction as integer) as integer
    
    If Direction > 0 & Direction <=10 Then Wind = 1
    Else: Wind = 0
    End If  
    
    End Public Function
    Essentially Direction is a numeric value for wind direction and i am seeing if it is between 0 and 10. When i type the following in excel [code] =Wind (A1) it returns #VALUE
    Any help would be appreciated
    Last edited by AAE; August 6th, 2011, 07:49. Reason: add code tags

  • #2
    Re: Public Function VBA #VALUE Error

    You need to put you VBA code into code tags

    Comment


    • #3
      Re: Public Function VBA #VALUE Error

      Hello oasiscolts18,

      Welcome to Ozgrid.
      While we're glad to have you on board, please take the time to read the forum rules.

      All VBA code posted in the forum must be wrapped in code tags, which you omitted, including single-line code snippets.
      I've added the tags for you this time only. Be sure to use them in future posts.

      How to use code tags

      [code]
      your code goes between these tags
      [/code]
      ---------------------------------------------------------


      Code:
      Option Explicit
      
      Public Function Wind(Direction As Long) As Integer
           
          If Direction > 0 And Direction <= 10 Then
              Wind = 1
          Else
              Wind = 0
          End If
       
      End Function
      AAE
      ----------------------------------------------------

      Forum Rules | Message to Cross Posters | How to use Tags

      Comment

      Working...
      X