Match index & concatenate help!!

kwt890

New Member
Joined
Feb 6, 2015
Messages
7
Hello All,

So I want to return a text value based on 4 criteria. I can do this with the Index Match function, however I want to concatenate ALL text values found in the column that match the 4 criteria into a single cell seperated by "; ". I desperately need help on this! The data would look like below as a sample (Columns A,B,C,D,E)

Region TypeStatusAudit NameMonth
AsiaInternalCompleteAPACJanuary
AsiaInternalCompleteKorea GOJanuary
EuropeExternalCompleteUK sheffieldJanuary

<TBODY>
</TBODY>








I want the audit names concatenated into a single cell if Region="Asia", Type="Internal", Status="Complete", and Month="January". Therefore, the result in the cell should read "APAC; Korea GO". If I just have the function then I would then have the usability to search other criteria, etc.

Any help on this would be greatly appreciated!

-Taylor
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Hello All,

So I want to return a text value based on 4 criteria. I can do this with the Index Match function, however I want to concatenate ALL text values found in the column that match the 4 criteria into a single cell seperated by "; ". I desperately need help on this! The data would look like below as a sample (Columns A,B,C,D,E)

Region
Type
Status
Audit Name
Month
Asia
Internal
Complete
APAC
January
Asia
Internal
Complete
Korea GO
January
Europe
External
Complete
UK sheffield
January

<TBODY>
</TBODY>








I want the audit names concatenated into a single cell if Region="Asia", Type="Internal", Status="Complete", and Month="January". Therefore, the result in the cell should read "APAC; Korea GO". If I just have the function then I would then have the usability to search other criteria, etc.

Any help on this would be greatly appreciated!

-Taylor



Okay - So I found this UDF and it works perfectly. However it only uses 1 criteria to return concatenated results. How do I change the code to have 4 total criteria met?
Code:
Function ConcatIf(ByVal compareRange As Range, ByVal xCriteria As Variant, Optional ByVal stringsRange As Range, _
                    Optional Delimiter As String, Optional NoDuplicates As Boolean) As String
                    
    Rem the first three argumens of ConcatIf mirror those of SUMIF
    Rem the Delimiter and NoDuplicates arguments are optional (default "" and False)
    Dim i As Long, j As Long
    
    With compareRange.Parent
        Set compareRange = Application.Intersect(compareRange, Range(.UsedRange, .Range("a1")))
    End With
    
    If compareRange Is Nothing Then Exit Function
    If stringsRange Is Nothing Then Set stringsRange = compareRange
    Set stringsRange = compareRange.Offset(stringsRange.Row - compareRange.Row, _
                                            stringsRange.Column - compareRange.Column)
    
    For i = 1 To compareRange.Rows.Count
        For j = 1 To compareRange.Columns.Count
            If (Application.CountIf(compareRange.Cells(i, j), xCriteria) = 1) Then
                If InStr(ConcatIf, Delimiter & CStr(stringsRange.Cells(i, j))) <> 0 Imp Not (NoDuplicates) Then
                    ConcatIf = ConcatIf & Delimiter & CStr(stringsRange.Cells(i, j))
                End If
            End If
        Next j
    Next i
    ConcatIf = Mid(ConcatIf, Len(Delimiter) + 1)
End Function
 
Upvote 0

Forum statistics

Threads
1,216,430
Messages
6,130,573
Members
449,585
Latest member
c_clark

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top