Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Jul 2001
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to make functions (2000 sr-1)

    Hello all

    Okay so I want to make a function that will run under any workbook that I open.
    I tried to code this as an example IN a workbook to use WITHIN a workbook but It didn;t work and I don;t know why

    Public Function myfunc(ByVal number As Integer)
    number = number * 15
    myfunc = number
    End Function

    Pretty simple, then i went into excel and wrote in a random cell =myfunc(10) only to get the infamous #name? error.....WHY??????!!!!!???????

    I figured that if I can make this work then I could code a function into the personal.xls worksheet and make the function work with any workbook. Also, would my funciton work if I had a cell reference like =myfunc(a1) or something

    I am just starting to learn function so any will help/recommendations would be great.

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: how to make functions (2000 sr-1)

    The #Name error says that Excel can not find the function. There are a number of possibilities:

    1- If the function is in the same workbook as the formula, then the function name must be spelled differently in the function and in the formula.

    2- If the function is in a different workbook, then you must specify the workbook name in the formula, lke this: =Personal.xls!myfunc(10)

    If the workbook containing the function is open, then you should be able to select a cell and choose Function from the Insert menu. Select "User Defined" from the category list and your function should be listed in the other list box. CLick on it and it should show you the syntax to execute it.
    Legare Coleman

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •