• FINDSERIES (Excel 03)

    Author
    Topic
    #465686

    I’m trying to use a formula (FINDSERIES) and I’m getting a #NAME? error. I have the following setup in VB. I’ve used the same function successfully in other excel files, but I’m failing here. What am I doing wrong this time?

    Public Function FindSeries(TRange As Range, MatchWith As String)

    For Each cell In TRange
    If cell.Value = MatchWith Then
    x = x & cell.Offset(0, 1).Value & “, ”
    End If
    Next cell

    FindSeries = Left(x, (Len(x) – 2))

    End Function

    Viewing 6 reply threads
    Author
    Replies
    • #1197704

      Is the module containing the function in the same book as where you are trying to use the function?
      If you are trying to use it in a workbook other than the one in which it is located, you must refer to the location book:

      Code:
      =Book1!FINDSERIES(a1:a10,"ASDF")
      

      I would also suggest using Application.Volatile in your function so that it updates when a cell is changed

      Code:
      Public Function FindSeries(TRange As Range, MatchWith As String)
      Application.Volatile
      For Each cell In TRange
      If cell.Value = MatchWith Then
      x = x & cell.Offset(0, 1).Value & ", "
      End If
      Next cell
      
      FindSeries = Left(x, (Len(x) - 2))
      
      End Function
      
    • #1197705

      Did you intend to post this in Excel forum, or are you trying to use Automation of Excel in an Access VBA module? If it’s the latter the automation bit would need to be defined first.

    • #1197708

      Yes. My apologies as this was meant to be posted in spreadsheets instead of databases. I tried the adjustments and I’m still receiving the same error. Strange!

    • #1197711

      Can you post a sanitized book where you are receiving the error? You function works fine when I tried to run it.

    • #1197712

      I’ll move the thread to Spreadsheets then. Thanks for the reply.

    • #1197725

      The function must be in a normal module (not worksheet, workbook or class module) and you have to have macros enabled.

    • #1197753

      That was it! I had it in the workbook, not in a normal module. I put it in the wrong place. Thanks everyone!

    Viewing 6 reply threads
    Reply To: FINDSERIES (Excel 03)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: