+ Reply to Thread
Results 1 to 4 of 4

Getting "this function takes no arguments" and "#NAME?" error

  1. #1
    Registered User
    Join Date
    08-29-2006
    Posts
    1

    Getting "this function takes no arguments" and "#NAME?" error

    I'm a newbie.

    I'm trying to make my first VBA function work, and I know I'm very close, but I'm hitting some roadblocks.

    I've got a couple functions defined in a single module, and both functions appear in the User-Defined list in the Insert Function dialogue. But, even though both functions take arguments, the dialogue is telling me that they take no arguments.

    Secondly, whether I put arguments in or not, I only get a "#NAME?" error, which leads me to believe that for some reason Excel is not finding the functions properly.

    I've tried all the little slight adjustments I can think of, and I've even tried turning the macro security to low, hoping that it might somehow be related. Further, when I tried downloading a sample workbook from an online Excel/VBA tutorial, the sample code gave me the exact same trouble, so I'm wondering if there's some preference or setting somewhere that I need to turn on/off...

    Just in case, here are my functions. Obviously, the second one is just something simple I'm trying to test with.

    I would really appreciate any insight or ideas on what I can try. Thanks in advance.


    Function GetNth(team As Range, pos As String, nth As Integer) As String
    Dim row As Integer
    Dim done As Boolean
    Dim found As Integer
    Dim result As String

    row = 0
    done = False
    found = 0
    result = "..."

    Do Until (done = True) Or (row = 14)
    row = row + 1
    If team.Cells(row, 1) = pos Then
    found = found + 1
    If found = nth Then
    result = team.Cells(row, 2)
    End If
    done = True
    End If
    Loop
    GetNth = result
    End Function

    Function AddOne(num As Integer) As Integer
    AddOne = num + 1
    End Function

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,493
    works fine for me although nothing happened when I filled in the formula,

    =GetNth(A4,B4,C3)

    hit Alt F11
    select insert
    module
    paste your function code in the new module

  3. #3
    Registered User
    Join Date
    12-31-2014
    Location
    Camden, NJ
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Getting "this function takes no arguments" and "#NAME?" error

    I'm getting the same behavior in a workbook that had no problem recognizing the VBA module functions yesterday. Just reopening the workbook produced the problem. Hitting Alt-F11 shows the function under Modules, and it appears on the Insert Function list but without its arguments. Every reference to every function in the module worked yesterday and not today, and the workbook hasn't changed.

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,493

    Re: Getting "this function takes no arguments" and "#NAME?" error

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1