+ Reply to Thread
Results 1 to 7 of 7

Multiple returns in-line

Hybrid View

  1. #1
    Registered User
    Join Date
    05-09-2012
    Location
    A
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Multiple returns in-line

    Not quite it, but thanks GeneralDisarray.

    I have modified the attachment to show the result I am looking for.
    The purpose of the formula is to automatically track the "Action ID" numbers assigned to items.
    e.g. Pumps are a problem(Item) - I assign actions to fix the item (A01, A02). When the actions have been entered into the Action Register they automatically appear in the Item Register (as shown in the attachment). So one item may have many actions assigned to it, this is just a way of tracking them.

    I hope that makes sense.

    Thanks.

    HSE Register2.xlsx

  2. #2
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Multiple returns in-line

    Attachment demos this solution -- NOTE you will need to enable macro content in order for the UDF (user-defined-function) to work.

    The code below will help you remember what to enter into the function and in what order: Look in the I column to see how this UDF was implemented in the worksheet.

    
    Option Explicit
    
    Public Function getAllMatching(ValueToMatch As String, MatchColumn As Range, ReturnOffset As Integer) As String
        Dim i As Long
        Dim cell As Range
        Dim values() As String
        ReDim values(1 To 1)
        
        For Each cell In MatchColumn
            If cell.Value = ValueToMatch Then
                ReDim Preserve values(1 To UBound(values) + 1)
                values(UBound(values)) = cell.Offset(0, ReturnOffset).Value
            End If
        Next cell
        
        On Error GoTo endfunction
        For i = 2 To UBound(values)
            getAllMatching = getAllMatching & "," & values(i)
        Next i
        'trim lead comma'
            getAllMatching = Right(getAllMatching, Len(getAllMatching) - 1)
        Exit Function
    endfunction:
        
    End Function
    Attached Files Attached Files
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

+ 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